JSP form posting

G

gouqizi.lvcha

If I have a jsp page containing a form without action, does it always
mean it will post to itself? I am trying using Tomcat6 and it actually
post to itself.

However, I want to make sure whether this is the default behavior for
most popular browsers or HTML specification or JSP specifiction?

Example form like the following

<form>
<i>Please enter your name: </i><input name="name">
<input type="Submit">
</form>
 
A

Arne Vajhøj

If I have a jsp page containing a form without action, does it always
mean it will post to itself? I am trying using Tomcat6 and it actually
post to itself.

However, I want to make sure whether this is the default behavior for
most popular browsers or HTML specification or JSP specifiction?

http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.3

claim it is required.

http://www.w3.org/TR/REC-html32#form

claim it is not required but does not specify a default

http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.1

claims that it defaults to the page itself.

I have never seen it not being interpreted as meaning page own
URL when omitted.

But as I read the above then to comply with current HTML standards
you should server side generate the correct action attribute.

Arne
 
A

Arved Sandstrom

If I have a jsp page containing a form without action, does it always
mean it will post to itself? I am trying using Tomcat6 and it actually
post to itself.

However, I want to make sure whether this is the default behavior for
most popular browsers or HTML specification or JSP specifiction?

Example form like the following

<form>
<i>Please enter your name: </i><input name="name"> <input type="Submit">
</form>

By the HTML 4 specification an action attribute is required for forms.

Most browsers do submit to the current page if there is no action
specified. The older HTML specs said that the action attribute was
optional, and if your HTML is old enough even said that the default
action is to submit to the base URI of the document.

Strictly speaking browsers should barf with HTML 4 in this situation, but
this is the real world. You should definitely not rely on this behaviour
though.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top