• Post Reply Bookmark Topic Watch Topic
  • New Topic

Form method and type  RSS feed

 
Jeff Dube
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am working with a form and i have had a problem with the form tag.
When i write :
<form name="Personnel" method="post" action="ShowValues.jsp" enctype="multipart/form-data" onSubmit="return validateMe(this)">
I am unable to get parameter in my ShowValues.jsp page but when i write :
<form name="Personnel" type="post" action="ShowValues.jsp" enctype="multipart/form-data" onSubmit="return validateMe(this)">
Everything is okay but all the parameters are shown in the url.
Why???
Thanks
Jeff
 
Jeff Dube
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to say that with the method="post" i get a null value for all fields (request.getParameter...)
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With method="get", you will have all your name value pairs in the URL.

But with enctype="multipart/form-data" you have two separate problems. I'm pretty sure this must be method="post", so you don't have the URL problem... but there is a problem with parsing this post type, and an additional problem with certain web/application containers.

HttpRequest objects are only able to be made from the standard "application/x-www-form-urlencoded" type of post.

If you are doing multipart (probably because you are doing file upload), then you need a MultiPart processor. A fairly good one is available from http://www.servlets.com/cos

The additional container problem which I mentioned is not a problem on Tomcat. But if you are writing a servlet to run as part of a J2EE application, running under a 'high end' (for one, iAS) application server, then the web container will actually attempt to parse this for you. Because it only knows how to parse a "application/x-www-form-urlencoded" post, it will encounter an "unexpected end of part" error, and (flakey!) it will drop the whole request, and pass null to your servlet. So even if you have the COS multipart processor, it receives null from your servlet runner! ARGH. But like I said, if you just use Tomcat you don't have this second problem.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!