java2db

How to get the Radio Button value in Servlet ?



The Radio Button get the form data in servlet allows the user to choose only one option from a set of options.The choices are mutually exclusive.Use its logical name to get the radio button value in servlet.

 

Radio Button declaration :
How to get the Radio Button value in Servlet
For pre-checked radio buttons get the form data in servlet, add checked inside the <input> element.

<input type=”radio” name=”color” value=”Red” checked> Red

How to get the Radio Button value in Servlet You must declare a group of radio buttons with the same name.The radio button value goes to the server,not the display text.

 

 

How to get the Radio Button value in Servlet Code to  get the Radio Button value in Servlet :

String color = request.getParameter(“color“) ;

 

 

How to get the Radio Button value in ServletExample to get the Radio Button value in Servlet :

index.xml

GetRadioServlet.java

web.xml

Execution result :

Select a radio button from the screen.

Send it to the server. The server sends back the response as follows.




Related Posts :
Kill or invalidate session using session id ( concurrent login )
Servlet Filter ( Request and Response filters in servlets ) example
URL rewriting in servlets ( Servlet session tracking )
Servlet Cookies ( Servlets session tracking with cookie )
Hidden form field in servlets ( Servlet session tracking )
Request attributes in servlet with an example ( Attribute scope )
Session attributes in servlet with example (Attribute scope)
ServletConext Attributes in servlet ( Attribute scope )
   [will not be published]



^ <