Results 1 to 3 of 3
  1. #1
    srinivas2828 is offline Member
    Join Date
    Sep 2009
    Posts
    10
    Rep Power
    0

    Default 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
    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
    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
    Java 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

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Use a bean for your JSPs and don't put Java code inside JSPs.

  3. #3
    srinivas2828 is offline Member
    Join Date
    Sep 2009
    Posts
    10
    Rep Power
    0

    Default 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

Similar Threads

  1. Disable Radio button
    By AJG in forum New To Java
    Replies: 3
    Last Post: 05-10-2011, 11:09 AM
  2. radio button checked by default
    By whiteasshweta in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 07-06-2009, 01:11 PM
  3. Double click radio button
    By mandragora in forum AWT / Swing
    Replies: 11
    Last Post: 11-10-2008, 11:06 AM
  4. How to use SWT Radio Button
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 02:25 PM
  5. Reacting Radio button event
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 07:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •