How can I catch the radio button action in jsp?
actually I am developing a java program using JSP and forms.the first page is used to enter two parameters and then there will a proceed button to go further ahead then second page will diaplay options with radio buttons like add,sub,multiplication,division. Among these radio buttons user need to select one option then he needs to click on result button. According to user selection the result should be diplayed.I have writtenthree jsp programs to meet my requirements named as firstpage.jsp,secondpage.jsp and operations.jsp but I dont no how to catch the action from the user selection and please take a look at my code
firstpage.java
Code:
<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.java
Code:
<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
Code:
<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);
int sub =Integer.parseInt(s1)-Integer.parseInt(s2);
int mul=Integer.parseInt(s1)*Integer.parseInt(s2);
int div =Integer.parseInt(s1)/Integer.parseInt(s2);
%>
</body>
</html>
please help me out
How can I catch the radio button action in jsp
my questions is that it is possible ? I need to develop using JSP and forms only
because my friends has already inplemented using beans but i am trying in different ways