RadioButton Example

RadioButton Example

Posted in : Java Posted on : June 11, 2011 at 6:40 PM Comments : [ 0 ]

In this section we will show you how the radio button is used.

RadioButton Example

In this section we will show you how the radio button is used. The following example illustrate you the use of Radio button. Radio button has a feature that it selects only one item at a time. The example given below is describing its features.


<title>Radio button example</title>
<form method="get" action="RadioButton">
<h2>Select your favorite dish</h2>
<p><input type="radio" name="dish" value="Indian"> Indian</input></p>
<p><input type="radio" name="dish" value="Continental">
<p><input type="radio" name="dish" value="Chinese"> Chinese</input></p>
<p><input type="radio" name="dish" value="Italian"> Italian</input></p>
<p><input type="radio" name="dish" value="Russian"> Russian</input></p>
<input type="submit" value="Submit"></form>

import javax.servlet.*;
import javax.servlet.http.*;

public class RadioButton extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String value;
value = req.getParameter("dish");
PrintWriter pw = res.getWriter();
pw.println("<html><body bgcolor=green>");
pw.println("<h3>Your favorite dish is = <font color=yellow>" + value
+ "</font></h3>");



Output :

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics