I'm making a web app with 2 check boxes. I used this code to capture the check box value.
`@WebServlet(name = "cookie", urlPatterns = {"/cookie"})`
public class cookie extends HttpServlet {
@Override
public void service(HttpServletRequest request,HttpServletResponse response) throws IOException{
String uname = request.getParameter("username");
String password = request.getParameter("password");
PrintWriter out = response.getWriter();
String secf = request.getParameter("secf");
String hof = request.getParameter("hof");
if(uname.equals("admin") && password.equals("admin")){
if(secf == null ? hof ==null : secf.equals(hof)){
out.print("both nc");
}
else if(secf.equals("sfTrue")&& hof==null){
out.print("sf t");
}
else if(hof.equals("hofTrue")&& secf==null){
out.print("ho t");
}
else
{
out.print("b c");
}
out.print("both not checked");*
}
else
out.print("Cheked");*/
}
else
out.print("Fail");
}
But the problem is when the hof is checked it throws nullpointer exception. Other incidents works
Aucun commentaire:
Enregistrer un commentaire