• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

File uploading and data collection problem

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i set the enctype="multipart/form-data" and method="post" and this form contain two input text type fields along with the file.
<form enctype="multipart/form-data" method="post">
<input type="text" name="f1">
<input type="text" name="f2">
<input type="file" >
</form>

When i collect the data from request in servlet like this..
String name=request.getParameter("f1");

The output is null..
but i set the method="get"
then i get the text field value.

So how can i get text field value using method="post" enctype="multipart/form-data"
request.getParameter("f1");
 
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you putting your String name=request.getParameter("f1"); in public void doGet(...) or public void doPost(...)?
It sounds like you are placing your getParameter( "f1" ) ; in doGet(...).
Try putting it in doPost(...) and see what happens.
HTH
 
faisal ishaque
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get the values in post method ...... but i get null
but when i get these values in get method its work fine.....
so how can i get these values in post method with enctype="multipart/form-data"
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
Go for the search option on this site. Search for "multipart form data"
this would surely help you, as it has been discussed quite a lot of time. In brief I would say that, multipart request is not treated is the same was as a normal request.
Assuming that your stream contains a String, boolean, char and a byte, in that order, the following code shows how to extract the contents.

Note that you have to extract the contents of the stream in the same order in which it is populated.
ref. here
hth
MB
[ November 08, 2003: Message edited by: Malhar Barai ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In multi-part messages, the form fields come in as their own parts. I'm not sure where your server puts all the parts, but if you have access to a collection of them, look through and see if your form fields are among them.
 
    Bookmark Topic Watch Topic
  • New Topic