• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get form parameters data to a servlet?

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



1)how above form parameters like radio button data,drop down menu data can be transfered to the servlet(I mean can I get it using request.getparameter(); or any other way to get this data from the form to a servlet & then to display it ajsp page?





 
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thejaka samarakoon wrote:I mean can I get it using request.getparameter(); or any other way to get this data from the form to a servlet & then to display it ajsp page?


If an input has just one value (eg: radio button), you can simply get it using getParameter(). For getting multiple values (eg: check boxes), have a look at HttpServletRequest.getParameterValues(String).
 
thejaka samarakoon
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Devaka Cooray ,i'll upload my AddServlet(below). Which is the one having the(Servlet) code for run the application with a created mysql database.but this code compiles successfully, but doesn't add values to the database(I created database correctly,can you help to solve this problem?


 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked the server log for the problem cause? What has happened should have logged down there.

Beside your database problem, pay attention on....

- Invoking JDBC codes directly from your servlet class is not a good practice. You should have separate classes for database access.
- Storing the inputs without having proper validations is inherently insecure and prone to SQL injection attacks.
 
thejaka samarakoon
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Devaka Cooray,
Is it my servlet codes are right?I mean the request.getParameter() values to get form data?
 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic