I am writing a web service. I use java, servlet, jetty, freemarker, hibernate, mysql (just in case I listed everything).

In html file there is a label with several fields (tr), in the first column of which there is a checkbox.

The idea is as follows:

  1. I put a flag for some field
  2. My servlet sees that the checkbox has somehow changed (either a new class has been added, or some data- * attribute has been added, xs what)
  3. Starting to operate with data from the selected row.

Tell me how to do this?

If in the process of communicating with you either I add the code, or I will inform you about something else. It does not come to my mind what can be done, so for the time being I will still be looking for a google.

  • checkbox has value attribute try to read this parameter in servlet from HttpServletRequest req - Prahvessor
  • Find and read the literature about the form html - Sergey

1 answer 1

The servlet will not be able to track changes on the form, you will need to send the form.

Example:

 <form action="${pageContext.request.contextPath}/myservlet" method="post"> <input type="radio" name="radio1" /> <input type="submit" value="submit" /> </form> 

In the servlet itself, the address /myservlet will only accept the variable

 request.getParameter("radio1") 

[UPD]
You can wrap the table in a form, something like this will be released:

 <form> <table> <tr> <td> <input type="text" name="someText"> </td> <td> <input type="radio" name="istextChaned"> </td> </tr> </table> </form> 
  • Yes, it really turns out to get information that the checkbox is selected. But the following problem arises: This checkbox must be in the form. And I have such a checkbox in the table, and the form sending the post-request does not contact the table. - Vorobey.A