Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Buttons and JSP 1

Status
Not open for further replies.

aarushi2001

Technical User
Nov 16, 2005
109
US
Hi,

I have a form with radio button field which is optional. If a user hits submit without checking any value for radio button, I get an error page. How can I catch this exception?

Thanks
 
What is the error message?

Dave



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Thanks Dave,
I get null pointer exception error. The problem is if I hit enter with out checking radio button, I get null value. But I need thr information entered by user as it is stored in a table.
The easiest way is to set a default value for radio button if nothing is checked.

Is it possible?

Thanks.
 
I'm guessing the null error is coming from the top of your JSP that is called from your FORM's ACTION parameter. Yes? If so, can you post the code where the "offensive" line is?

If you can edit that JSP, do a check for null:

Code:
String myRadio = request.getParameter("myRadio");
if(myRadio == null)
 myRadio = "";

I forget if that's how you retrieve a radio value.

The other thing to try is to do some client-side (JavaScript) form validation before the form submits. Then it becomes a JavaScript question. forum216

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
thank u Dan.. that is exactly what I was looking for. My condition (myRadio == null) was incorrect :)

Thanks a lot
 
'glad to help! Thanks for the star.

Happy New Year!

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top