The directory structure is as shown below
WEB-INF
|
|-xfolder
|-sample.jsp
|-images/man/upload.html
|
Now how to submit the upload.html form to sample.jsp page
I tried like this in upload.html file
<form method="post" action="../sample.jsp" >
......
.......
</form>
But it not worked.
Help me..
First, if you are uploading files, you need to include enctype= multipart/form-data in your form declaration
Second -and most likely your problem- your form's action is wrong. It should be: action="../../sample.jsp" since you need to go up 2 levels: one for man and one more for images to get to the root where sample.jsp is located.
Related
I am trying to get a search box to post its content into a searchbox on another domain, using the html post method, however its not working after being redirected to the second site the search box remains empty on site 2.
Both servers belong to the same business and I have access to both, can someone tell me what I could do without using java to get the contents from the input box 1 on site 1 posted to the input box 2 on site 2
here is the line of code I am using on the first site.
form action="https://site2.com/cart.php?a=add&domain" method="post"
Thanks
You''ll need to catch and process both the GET arguments (in your action URL) and the POST stream (from the form elements) in the site2.com/cart.php file that you are using as the action.
Assuming the input box on site1 is named inputBox and is contained in the form with that action, when the form is submitted the site2.com/cart.php script can access the value at $_POST['inputBox'] - ie, wherever that goes on site2, you could do
<form name="someformonsite2" action="....">
<input type=text
<?php
if((!empty($_POST['inputBox'])&&(passes_your_validation($_POST['inputBox']))){
print("value=\"".$_POST['inputBox']."" );
}
?>
size=12 maxlength=11>
<!-- rest of form follows -->
Which would effectively send to the browser:
<input type=text value="SomeVal" size=12 maxlength=11>
My first folder is called Tests.
Inside Tests, I've got a HTML file called Tomel.
Using relative link, I stated:
<p> Here's THE IRQI WANNABEE KURD'S Page </p>
Which links Tomel's file to Jasser and it works.
However, to do the reverse and go back from Jasser to Tomel, I stated:
<p> Tomel's Page </p>
But it doesn't work. Help me out here please.
../Test2/Tomel.htm
Tomel's Page inside inside the Test2 directory, but that is where you are looking for it.
From ur information provided
Your directory should look like
Tests/
|
---Tomel.html
---Test2/
|
---Jasser.html
Therefore, if you using the following in Tests/Tomel.html
Test2/Jasser.html
No error as your current directory is Tests/
and Tests/Test2/Jasser.html exists
However, if you are in Tests/Test2/Jasser.html, if you do the following
../
You current directory will become Tests/, therefore, Tomel.html is at the same directory
So the answer for Jasser to Tomel should be
../Tomel.html
I'm probably missing something very basic but I'm stumped.
My HTML form (in a Django template):
<form id="site_signout" method="POST">{% csrf_token %}
<input type="submit" value="sign in">
</form>
In my browser (running my site on the dev server), when I click on the <input> button, nothing happens. Like, nothing nothing. Normally something would show in Terminal such as
[22/Apr/2014 08:29:17] "POST /my/url/ HTTP/1.1" 302 0
Or in Firebug, I would see something about a POST in the HTML tab of the Net panel. But I see nothing. Literally nothing happens when I click the button.
Other submit buttons (for other forms) on my site work just fine.
What could be causing this?
EDIT: The relevant part of my view is:
if request.method == 'POST':
pdb.set_trace()
That's all I have for the form right now because I want to examine what is posted in this scenario before I write more code.
EDIT: My intention is to simply POST to the same page (URL) that the form is on. As I understand it, this should be achievable by simply omitting the action attribute of the <form> element altogether. This is how I started but since it didn't work, I tried a couple of other options such as action="/", which is what I originally posted above. However, my intention is to have the form POST handled by the same view as the form itself. Therefore I've edited my original code sample to omit the action attribute altogether to clarify this point.
Here is my top-level urls.py:
urlpatterns = patterns('',
url(r'^inspection/', include('main_inspection.urls') ),
...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Here is main_inspection.urls with the relevant URL:
urlpatterns = patterns('main_inspection.views',
url(r'^home/$', 'home', name="inspection_home"),
...
)
The URL for the view in question (on my dev server) is:
http://127.0.0.1:8000/inspection/home/
The solution turned out to be quite silly, and not discoverable by anyone reading the above question:
I had some JS capturing any click event happening inside the div in which the form was located.
Lesson learned: when something really strange seems to be happening at the basic HTML level, check to make sure you didn't write any stupid JS code that is producing the effect.
Your URL about "/" should be something like this:
...
url(r'^$','yourapp.views.index',name="base_address"),
...
It will run "yourapp.views.index" when you call "/" address.
If you want to set an address in you form action attribute try to set name of address instead:
<form id="site_signout" method="POST" action="{% url 'base_address' %}">{% csrf_token %}
<input type="submit" value="sign in">
</form>
We defined "base_address" name in urls that assigned to "/" address and then used that with "url" method in template.
When I was learning Php with Mysql, I got a problem :
<form action="?" method="POST">
.
.
.
</form>
Why do we put "?" in the action attribute?
PS: this form was for inserting text into a database.
Actually, I have an Index.php file which is the controller, and 2 files (form.html.php and joke.html.php as templates). In the tutorial, I first clicked on a link "add joke" to include the form.html.php file and in this form there is <form action="?"> </form> and a submit <input>. When I click on submit, the controller index tests and executes the inserted SQL query.
Thanks.
Personally don't ever do that.... Use action="action.php" or use action="" post to the current URL.
Not sure what you are trying to accomplish with ? in the action attribute.
"We" don't and "You" shouldn't do so either.
If you want to POST the data to the current URL, leave it empty, i.e. action="".
If you want to POST to another URL, put that URL in there, e.g. action="save.php".
Hi im new in jsp/servlets, i have a basic question about relative or abselute path:
i have the following hierarchy, using netbeans:
Web Pages
| |-Status
| |-clientRequests.jsp
| |-index.jsp
| |-WEB-INF
| |-professional.jsp
index.jsp and the Status folder and WEB-INF folder in root path.
inside the Status folder we have the clientRequests.jsp file.
inside the WEB-INF folder we have the professional.jsp file.
in the index.jsp i have done dispacher to professional.jsp,
inside professional jsp i have <iframe src="Status/clientsRequests.jsp"></iframe>
inside the clientsRequests.jsp i have
<%
response.setHeader("Refresh", "5;url=../index.jsp");
%>
that means that every 5 sec will be refresh to the clientsRequests.jsp file, and then go to the "controller" which is index.jsp.
now what i wanted to be that every 5 min, only the iframe refreshed and not the hole page.
my problem: in the second refresh it gives me 404.
i tried to play with that and i did something ugly like:
String a = (String)session.getAttribute("nav");
if(a == null){
session.setAttribute("nav", "aaa");
response.setHeader("Refresh", "5;url=../index.jsp");
}else{
response.setHeader("Refresh", "5;url=index.jsp");
}
and its working, but i dont want wo leave that like this way...
do you have any suggestions?
thank you!
Somehow your response is setting header for the parent of the iframe too. Put the below line in the of clientsRequests.jsp.
<meta http-equiv="refresh" content="5">
one Alternative would be to move the clientRequests.jsp to the same level as index.jsp.
That way in your code you can always do this
response.setHeader("Refresh", "5;url=index.jsp");
One advantage is with this set up , the <iframe src="Status/clientsRequests.jsp"></iframe> can be added to any of the JSP pages in your application and there is no change/impact in the servlet code