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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio problems?

Status
Not open for further replies.

TomBarns

Programmer
Feb 14, 2001
10
US
Hi
I'm trying to have two radios on my jsp page,for example i have radio1 and radio2,i need when i check radio1 to pop up a jsp page
that displays radio1 is on,the same when i check radio2 in need to pop up a jsp page that displays radio2 is on.
I'm trying that and i'm getting internal servlet error(java.lang.nullpointerException),iknow that i'm working on reference without initializing it.
How can i make it work?
thanks for your time.
Here is my source code:
//====================
<html>
<form action=&quot;radioResponse.jsp&quot;>
<body bgcolor=&quot;#996600&quot;>

radio1 <input type=&quot;radio&quot; name=&quot;radio1&quot; ><br>
radio2 <input type=&quot;radio&quot; name=&quot;radio2&quot; ><br>

<input type=&quot;submit&quot; >
</form>
</body>
</html>
//===========================
//==========================
<%if(request.getParameter(&quot;radio1&quot;).equals(&quot;on&quot;)){ %>
radio1 is on
<%}else{%>
radio1 is of
<%}%>

<%if(request.getParameter(&quot;radio2&quot;).equals(&quot;on&quot;)){ %>
radio2 is on
<%}else{%>
radio2 is off
<%}%>
//============================
 
[tt]
Code:
<%
  String radio1 = request.getParameter(&quot;radio1&quot;);
  String radio2 = request.getParameter(&quot;radio2&quot;);

  // if both params are nothing do nothing
  if(!(radio1.equals(&quot;&quot;) && radio2.equals(&quot;&quot;))) {
    if(radio1.equals(&quot;&quot;) // radio 1 was not selected
      out.println(&quot;Radio 2 is on&quot;);
    else // radio 2 was not selected
      out.println(&quot;Radio 1 is on&quot;);
  }
  else {/* do nothing */}
%>
[/tt]
I hope this helped! ;-)
- Casey Winans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top