Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If i try to read checkbox status from checkbox.html file after clicking the button instead of getting the values of checkbox it is downloading file which contains the status of checkbox.what i need to do solve this problem.


Here my checkbox.html file code:

HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="CheckBox" method="get">
<input type="checkbox" name="maths">Maths<br>
<input type="checkbox" name="social">Social<br>
<input type="checkbox" name="scince">Scince
<input type="submit" value="select subject">
</form>
</body>
</html>




and my servlet name is CheckBBox.java iit contains the code like:

C#
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("textt/html");
		PrintWriter out=response.getWriter();
		String statusofmaths=request.getParameter("maths");
		String statusforsocial=request.getParameter("social");
		String statusforscince=request.getParameter("scince");
		out.println("Status for Maths:"+statusofmaths);
		out.println("Status for scince:"+statusforscince);
		out.println("Status for socail:"+statusforsocial);
		out.println();
	      
	}

C#
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900