jeudi 24 mai 2018

setAttribute to checkbox with servlet

here is what I have:

JSP:

 <input type="checkbox" id="no_del_file" name="no_del_file" value="no_del_file" ><br />

Java:

 boolean cbState = request.getParameter( "no_del_file" ) != null;
            System.out.println("cbstate: "+cbState);
            if (cbState == true) {
                request.setAttribute("no_del_file", "checked");
                String checker=(String) request.getAttribute("no_del_file");
                System.out.println(checker);
            }

 RequestDispatcher dispatcher = request.getRequestDispatcher("/runButtonCommand.jsp");
            dispatcher.forward(request, response);

The problem is that the output is:

 cbstate: true
 checked

but the checkbox is not checked itself after the servlet returns the responds. The tick is removed for some reason.

Any ideas?




Aucun commentaire:

Enregistrer un commentaire