Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

form handling with radion buttons  RSS feed

 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple form (ex. survey.jsp) with text boxes and radio buttons. I am processing the form in another jsp page (ie. no beans, servlets etc.):

<form method="post" action="survey_thanks.jsp">

The textboxes are working fine. However, anytime I try to submit the form with a blank radio group, I receive a server 500 error. Here's what I have tried:



If a users leaves this unanswered, they will get a 500 error. How do I fix this?

I have tried this to "trick" the server, but I get the same error



Thanks,
Andrew
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am processing the form in another jsp page


I would be remisss if I didn't point out that this is considere extermely poor practice. JSPs are for rendering the view, servlets are for processing.

That said...

If a users leaves this unanswered, they will get a 500 error. How do I fix this?


A 500 error could be anything. Some further details about the error will be useful.

But taking a wild stab, I would suspect that somewhere after



you are probably referencing websiteRecommend which will be null in the case resulting in a NullPointerException.
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If any of the radio button is not selected, then the browser does not send the "websiteRecommend" parameter with the http request. The parameter will be set and will be sent with http request, if and only if any of the radio is selected.

Hence, Bear Bibeault's wild guess is quiet correct!
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that I should be doing all of the processing in servlets. I am ashamed. The problem was that our department needed a brief survey to quickly be distributed internally in my department, ASAP. However, based on the answers above, it appears that even if I did use servlets, I would still run into the same problems because an empty radio group does not get a vaule submitted to the form.

In general, how do you process radio buttons if the information that they provide is not required for your results? Does anyone have any suggestions or know of a good/basic jsp form tutorial?

Thanks,
Andrew
[ September 08, 2004: Message edited by: Andrew Hughes ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


To test for the condition. What else do you need?
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this, but for some reason, I still get the 500 error. I guess that I'll mess with it some more.

Thanks for the feedback.

Andrew
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repeat

A 500 error could be anything. Some further details about the error will be useful.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 500 error is very likely to be telling you that your JSP did not compile for some reason. It will be accompanied by a stack trace - the seemingly incomprehensible list of fully qualified class names, method names and line numbers beginning with an Exception and its description. Reading that should help you (or us if you're really stuck) identify the cause of your error.

Jules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!