Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot get the parameter?  RSS feed

 
mira yang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have two pages:
page1.htm:
<html>
<body>
<form name="myform" method="post" action="page2.jsp" enctype="multipart/form-data" >
name: <INPUT type="text" name="name" size=40 maxLength=40 ><br>
pic:<input type="file" size=40 name="File1" value=""><br>
<input name="next" type="submit" value="next">
</form>
</body>
</html>

page2.jsp:
<%
String name = request.getParameter("name");
String file1 = request.getParameter("File1");
out.print(name);
out.print(file1);
%>

the output is: nullnull

but when i remove the enctype="multipart/form-data" in page1.htm,i can got the name and file1;
why? and how i can got the parameter whitout remove enctype="multipart/form-data"?
[ July 26, 2004: Message edited by: Bear Bibeault ]
 
Ron Perich
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use Multipart forms, you cannot just ask the request to get the parameters for you, you need to parse out the form request and find the different parts.

Fortunately, if you are wanting to give it a try, the Apache commons toolset includes everything you'll need to upload a file.

Check out Apache for the API. I haven't used it yet, but it looks like it will work. I sure wish I had this around when I had the same problem; I wouldn't have spent so much time digging into the weeds of requests!

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