• Post Reply Bookmark Topic Watch Topic
  • New Topic

writing query

 
arun andrew
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i wrote a servlet which accepts two variables num(int) and nam(string) from an html form.now i want to write that data into the postgresql database.could some body show how i could write such a code.am fairly new to servlet programming...
regards
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You get the form values with 'request.getParameter(PARAM_NAME)'.
This method always returns Strings so you will need to convert your int values before inserting them into your database.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming you are new to servlet but not JDBC. just do what Ben said. get the parameter using request.getParameter(parameterName), convert into integer primitive, if required, then do whatever.

Tip: dont mix your JDBC code with your servlet code. Servlet should handle your request/response mechanism instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!