Java Prac 22 Radio
Java Prac 22 Radio
HTML File:
<!DOCTYPE html>
<html>
<body>
<form method="get" action="shashank_r">
<input type="checkbox" name="sub">JAVA
<input type="checkbox" name="sub">C++
<input type="checkbox" name="sub">PYTHON
<input type="radio" name="gen">Male
<input type="radio" name="gen">Female
</form>
</body>
</html>
Servlet File:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/shashank_r")
public class shashank_r extends HttpServlet
{
public void doGet(HttpServletRequest
req,HttpServletResponse res)throws
IOException,ServletException
{
String l[] = req.getParameterValues("sub");
if(l!=null)
{
System.out.println("Subjects are:");
for(String lang:l)
{
System.out.println("\t"+lang);
}
}
}
}
Output: