Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to pass button value from jsp to servlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 58
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic