• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass button value from jsp to servlet

 
vini chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

I am passing values from jsp to servlet by using this method :


in jsp :

<form action="UploadServlet" method="post"
enctype="multipart/form-data">
<input type="file" name="file" size="50" />

<input type="submit" name="bt" value="gi" />


</form>

In Servlet :

String bt = request.getParameter("bt");
out.print("button value" +bt);

But when the servlet runs i get value of bt as null. Please help.

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The buttons value is not submitted in the request. Why do you want to get it ?

(Please UseCodeTags the next time you want to post some code)
 
K West
Ranch Hand
Posts: 58
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request.getParameter() method doesn't work with enctype="multipart/form-data"
It requires help of upload library to do this. You may refer to this link for more details.
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are wrong...
request.getParameter() will work for the case enctype="multipart/form-data" and this is required while uploading file.
info: w3schools(dot)com/TAGS/tag_form.asp

K West wrote:The request.getParameter() method doesn't work with enctype="multipart/form-data"
It requires help of upload library to do this. You may refer to this link for more details.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinoth Thirunavukarasu wrote:You are wrong...
request.getParameter() will work for the case enctype="multipart/form-data" and this is required while uploading file.

No, you are wrong. In Servlets 2.x, getParameter() will not work with multi-part forms.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!