Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I catch radio button action in jsp

843840Sep 19 2009 — edited Sep 19 2009
I am developing a java program using JSP&forms, first page will ask user to enter two number and there is a small button to proceed to the next page and the second page will ask user to select any one of the radio buttons from among the list and the list typically contains addition.subtraction,multiplication,division,so after user selection user need to click result button,then according to user operation result should be displayed . to do this i have written three JSP programs using forms.
but in
dont no how to catch the radio action ,can some body tell me how can i do this
Firstpage.jsp
<html>
<head>
<title>POST METHOD</title>
</head>
<body>
<form  action="secondpage.jsp" method="POST" >
 FirstNumber:<input type="text"  name="FIRSTNUMBER"><br>
SecondNumber:<input type="text"  name="SECONDNUMBER"><br>
<input type="submit" value="Proceed" >
</form>
</body>
</html>
secondPage.jsp
<html>
<head>
<title>POST METHOD</title>
</head>
<body>
<form  action="Result.jsp" method="POST" >
ADD:<input type="radio"  name="ADD" value="ADD" ><br>
SUB:<input type="radio"  name="SUB" value="SUB" ><br>
DIV:<input type="radio"  name="DIV" value="DIV" ><br>
MUL:<input type="radio"  name="MUL" value="MUL" ><br>
<input type="submit"   value="Result" ><br>
</form>
</body>
</html>
Result.jsp
<html>
<head>
<title>ADD</title>
</head>
<body>
<% if(ADD==Result)
   String s1=request.getParameter("FIRSTNUMBER");
   String s2=request.getParameter("SECONDNUMBER");
   int add=Integer.parseInt(s1)+Integer.parseInt(s2);
   out.println("Result=" + add);      
   
   %>

</body>
</html>
anybody have idea..please tell me
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2009
Added on Sep 19 2009
1 comment
322 views