Nirmallya Ghosh
Nirmallya Ghosh

Reputation: 21

Get checked Radio Button Value from JSP to Servlet

In HTML/JSP,

<input type="radio" value="10" name="a">10 Records
<input type="radio" value="20" name="a">20 Records
<input type="radio" value="50" name="a">50 Records 

In Servlet,

String val= request.getParameter("a");
System.out.println("Record is : "+val);

Variable val returns null .

Upvotes: 1

Views: 13228

Answers (3)

Rashid Saleem
Rashid Saleem

Reputation: 1

I face same problem. I try this then it works fine.

<input type="radio" value="10" name="a">10 Records **</input>**
<input type="radio" value="20" name="a">20 Records **</input>**
<input type="radio" value="50" name="a">50 Records **</input>**

Upvotes: 0

Chathuranga Tennakoon
Chathuranga Tennakoon

Reputation: 2189

check whether your form specifies the method post. please refer below

<form action="/Servlet" method="post">
     <input type="radio" value="10" name="a">10 Records
     <input type="radio" value="20" name="a">20 Records
     <input type="radio" value="50" name="a">50 Records 
     <input type = "submit" value = "submit"/>
</form>

then it should work.

Upvotes: 2

Vicky Thakor
Vicky Thakor

Reputation: 3916

Hope you have code similar to this then it'll give you value of a

<form action="/Servlet" method="post">
     <input type="radio" value="10" name="a">10 Records
     <input type="radio" value="20" name="a">20 Records
     <input type="radio" value="50" name="a">50 Records 
    // submit button here
</form>

Upvotes: 3

Related Questions