File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How do I get request parameters when the form is encoded? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

How do I get request parameters when the form is encoded?

Bhavani R Gupta
Greenhorn

Joined: Jul 10, 2007
Posts: 4
Hello,

I have my jsp with enctype="multipart/form-data".when i submit my request, i am unable to get the request parameters in servlet.
How can I get form feild values in servlet ???

Its very urgent plzzzzz anyone help me....

Regards,
Bhavani


[BPSouther: fixed spelling error in subject line]
[ August 14, 2007: Message edited by: Ben Souther ]
Sahid Khan
Ranch Hand

Joined: Jun 27, 2007
Posts: 41
Here is a code snippet.


HTH.
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
I have done this before to upload a file and passed it a hidden field,
It worked fine with me.

Can you paste your code so that we can see what can be wrong in it.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Bhavani R Gupta:

Its very urgent plzzzzz anyone help me....


Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see EaseUp to find out why adding 'urgent' to your subject line or post can actually slow down responses to your question or stop them altogether.

Also, please see
UseRealWords
Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
"plz" is not a word in the English language.

Again, welcome to JavaRanch and good luck with your question.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

How you read form parameters depends on the library you're using to parse the multipart upload.

Check the documentation for the library you're using.
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
I am using struts for getting the content of uploaded file

My jsp is



My action is:



My form bean is:


Note the bold lines in action and the jsp. I have not used anything struts specific in sending the hidden parameter. I am successfully able to get the value of the dummy hidden parameter.

Can you paste your code so that one can get a close look at it.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'd be hesitant to offer any specific solutions until we know what upload libraries the original poster is using. If he's using Struts then this isn't the right forum to discuss the issue anyway.

Let's see what he's using before posting anymore code.
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Ok, here is the code using jsp and servlets only

The servlet is



The jsp is



Here the hidden parameter is successfully read. So there should not be any problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Amol Nayak:
Ok, here is the code using jsp and servlets only

The servlet is



The jsp is



Here the hidden parameter is successfully read. So there should not be any problem.


Request.getParameter() does not work with multipart requests.
Each upload library has its own methods for retrieving form parameters.
This is why I suggested that we wait to see which the original poster is using before posting any more code.
Bhavani R Gupta
Greenhorn

Joined: Jul 10, 2007
Posts: 4
Originally posted by Sahid Khan:
Here is a code snippet.


HTH.



Thankyou.It is working fine with item.getString()method.
Durga Krishna
Greenhorn

Joined: Apr 05, 2007
Posts: 28

[ February 21, 2008: Message edited by: Ben Souther ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Durga,
Rather than drag out old threads that already have lots of posts, please start a new thread with your new question. Threads with lots of posts tend not to be read; especially if they're old.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get request parameters when the form is encoded?
 
Similar Threads
Ensure correct sequence of printing of request parameters ?
doGet() but I don'tGet()
java bean question
doGet() calling doPost() problem -- URL line visible in destination page!
How to send