
<html>
<head>
<title>online exam</title>
</head>
<body>
<div align="center">
<form method="post" action="Tab">
<p>4.what is currency of USA?</p>
<input type="radio" name="d" onclick="getAnswer('a')" value="a "/>dollar
<input type="radio" name="d" onclick="getAnswer('b')" value="b "/>pound
<input type="radio" name="d" onclick="getAnswer('c')" value="c "/>rupees
<input type="radio" name="d" onclick="getAnswer('d')" value="d "/>yen<br />
</form>
</div>
</body>
</html>
package src;
import java.io.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Tab extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
int count=0,wrng=0;
String radio0=request.getParameter("a");
out.println(radio0);
if("c".equals(radio0))
count++;
else
wrng++;
out.println("<html><head><title>result</title></head><body>" +
"<div align=\"center\"><h1><u>Result</u></h1><p>correct answers are:</p>"+count+"<br/><p>wrong answers are :</p>"+wrng+"</div></body></html>");
out.close();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
public String getServletInfo() {
return "Short description";
}
}
Here the radio0 returns null value.pls advice me
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.