JSP – Fetching Value of Radio Button


Radio button in JSP with same name return a single value to request object. Request.getParameter with radio field name will return a value of checked radio button.
Suppose we have three radio button and name of radioButton, if we select b value radio button, and submit this JSP page to getValue.jsp page. We will get value of request object is b.



<title>Radio Button</title>


<form name="frm" action="getValue.jsp" method="post" >
<input name="radioButton" type="radio" value="a" checked="checked"/> a
<input name="radioButton" type="radio" value="b" /> b
<input name="radioButton" type="radio" value="c" /> c
<input name="goto" type="submit" value="Submit" />

Fetching request value in this page of radio button


<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
 String radioButton= request.getParameter("radioButton");
 System.out.println("radioButton ::"+radioButton);
 out.println("Radio Button Value :"+radioButton);


6 Responses to “JSP – Fetching Value of Radio Button”

  1. hari says:

    simple and clear explanatory code

  2. NhungLuu says:

    Thanks you.

  3. Roli says:

    useful for me too.

  4. prasanna says:


  5. Swati says:

    Quite good. Thanks …

  6. Rakesh says:

    i am doing the same but not getting any solution,
    and getting null value

Leave a Reply