Hello there,
I've got an issue probably derivated by unexperience.
I've got an html form wich should send text values and upload a file to my servlet.
The file upload works fine but on the tomcat screen the text values are null.
can anyone tell me where the problem is?
Thanks in advance.
screen code
Start Start doGet method
Start task step_1
null
null
part of the servlet code
System.out.println("Start doGet method");
//extract the task from the request
//String task = (String)request.getParameter("task");
//System.out.println(task);
if (1 == 1) {
System.out.println("Start task step_1");
//retrieving values
String title = (String)request.getParameter("title");
System.out.println(title);
String menu = (String)request.getParameter("menu");
System.out.println(menu);
Html form
<form name="createStep_1" action="<%=request.getContextPath()%>/step_1?task=step_1" method="post" enctype="multipart/form-data">
<font>Inserire il titolo </font><input type="text" name="title" id="title" value=""><br><br>
<font>Allegare un'immagine </font><input type="file" name="logo" id="logo" value=""><br><br>
<font>Indicare quante voci menu sono presenti </font><input type="text" name="menu" id="menu" value="1" size="3"><br><br>
<input type="submit" value="Continua">
</form>
-
cannot get request params (5 messages)
- Posted by: sandro sandro
- Posted on: March 01 2005 09:34 EST
Threaded Messages (5)
- Here PB by Kaede Jiang on March 01 2005 22:25 EST
- [reply] by sandro sandro on March 02 2005 03:42 EST
- [2 reply] by sandro sandro on March 02 2005 04:23 EST
- [reply] by sandro sandro on March 02 2005 03:42 EST
- cannot get request params by Thomas Nicolaisen on March 04 2005 15:50 EST
- cannot read request.getParameter() by viji vinaya on May 23 2005 18:01 EDT
-
Here PB[ Go to top ]
- Posted by: Kaede Jiang
- Posted on: March 01 2005 22:25 EST
- in response to sandro sandro
i think
you couldnt use the filefield and the textfield in the same time. -
[reply][ Go to top ]
- Posted by: sandro sandro
- Posted on: March 02 2005 03:42 EST
- in response to Kaede Jiang
seems quite strange, I don't think that is reason.
And actually, I made severals test even without the file upload, and still doesn't work. -
[2 reply][ Go to top ]
- Posted by: sandro sandro
- Posted on: March 02 2005 04:23 EST
- in response to sandro sandro
I made some other test, and porbably, you're not totaly wrong, in fact I tried to delete from the form the ENCTYPE="multipart/form-data" and it works, well, I can gets the text values but not the file.
Can anyone tell me why it happens? -
cannot get request params[ Go to top ]
- Posted by: Thomas Nicolaisen
- Posted on: March 04 2005 15:50 EST
- in response to sandro sandro
Try sending the task parameter as a hidden parameter in the form. You are doing a post after all...
<form..>
<input type="hidden" name="task" value="step_1"/>
...
</form>
Not sure if it helps, though. I haven't used the file type before.. -
cannot read request.getParameter()[ Go to top ]
- Posted by: viji vinaya
- Posted on: May 23 2005 18:01 EDT
- in response to sandro sandro
hi,
The reason is whenever you have the upload file the other content goes like this
-----------------------------7d533a1404c0
Content-Disposition: form-data; name="country"
US
-----------------------------7d533a1404c0
Content-Disposition: form-data; name="phone"
-----------------------------7d533a1404c0
Content-Disposition: form-data; name="upload"; filename="C:\vijiroot\RobPubQueries.txt"
Content-Type: text/plain
select pub_no,shrinkwrap_qty from fast_publication where project_code='kai' and
shrinkwrap_qty and pub_no in (select pub_no from fast_inv_prod where
project_code='kai' and binding='SH WR')
*************************************
where the name="country" is the textfield and the value is "US"
so we need to parse the data to get the textfield values
Thanks
Viji