File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Android Security Essentials Live Lessons
this week in the
Pass radio button/ text box responses from one page to another
Joined: Nov 30, 2011
Dec 28, 2011 19:11:39
I have a jsp screen1 with lot of radio buttons and a text box.
Once some of these radio buttons are selected and text box typed with a value
and submit button clicked, it has to update the postgre DB with the selected radio
button's text and the text box value.
On successfull updation of DB, it has to redirect to a jsp screen 2.
Currently i have the jsp screen 1 but i dont know how to get responses and proceed.
Please help me with a sample code.
It is urgent!
Joined: Jul 06, 2005
Dec 28, 2011 20:56:51
Sounds simple enough...
The form on jsp screen 1 has to have an action that will invoke a
<form action="/myServlet" method="post">
In your servlet doPost method, you retrieve the values of the parameters with request.getParameter(), and then invoke some
code to save them.
String selectedRadio = request.getParameter("radioControlName"); String inputText = request.getParameter("textfieldControlName"); Connection con = getDatabaseConnection(); PreparedStatement stmt = con.prepareStatement("Insert into someDatabaseTable(option, comment) values (?,?)"); stmt.setString(1, selectedRadio); stmt.setString(2, inputText); stmt.execute(); stmt.close(); con.close();
and then get a request dispatcher and forward to the next jsp:
Joined: Jan 11, 2012
Jan 11, 2012 05:05:30
selectedRadio = request.getParameter("radioControlName");
String inputText = request.getParameter("textfieldControlName");
the request.getparameter("radiocontrolname") if null then how do we check it
out.println("user did not choosen");
but the if condition not checking, I have this problem in jsp registration page . please guide me in this regard
I agree. Here's the link:
subject: Pass radio button/ text box responses from one page to another
Problem with radio button
JSP and Radio Buttons
transfer data from text box to multiple select list box.
Transfer the variable value from one jsp page to other
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014