title: How to pass data from table in JSP to Java controller?
body: <p>Please help me to solve a problem! 
  I have table created in JSP and filled with data from my DB, and the problem is - I have not idea how to access that JSP data from my controller.
  For example - I need to pass appropriate ID (just String) to my controller from JSP to execute Delete method.</p>
  
  <p>My jsp:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form action="/editCategory" method="POST"&gt;
  &lt;h3&gt;Existing categories&lt;/h3&gt;
  &lt;%
      List&lt;Category&gt; categories = (List&lt;Category&gt;) request.getAttribute("model");
      if (categories != null) {
  %&gt;
  &lt;table border="1"&gt;
      &lt;tr&gt;
          &lt;th width="24"&gt;ID&lt;/th&gt;
          &lt;th width="80"&gt;Name&lt;/th&gt;
          &lt;%--&lt;th&gt;&lt;/th&gt;--%&gt;
      &lt;/tr&gt;
      &lt;%
          for (Category category : categories) {
      %&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;%= category.getId() %&gt; &lt;% request.setAttribute("id", category.getId());%&gt;
          &lt;/td&gt;
          &lt;td&gt;&lt;%= category.getName() %&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type="submit" name="delete" value="Delete"/&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;%
          }
      %&gt;
  &lt;/table&gt;
  &lt;%
  } else {
  %&gt;
  &lt;b&gt;Categories list is empty :(&lt;/b&gt;
  &lt;%
      }
  %&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>My controller methods:</p>
  
  <pre><code>public Model getModel(HttpServletRequest req, HttpServletResponse resp) throws DBException
      {
          if (req.getParameter("submit")!=null){
              addCategory(req);
          }
  
          if (req.getParameter("delete")!=null){
              deleteCategory(req);
          }
          categories = categoryDAO.getCategories();
          return new Model("/editCategory.jsp", categories);
  
      }
  
  private void deleteCategory(HttpServletRequest req) {
          System.out.println(req.getAttribute("id") + " printed");
      }
  </code></pre>
  
  <p>For now I want just to see that correct ID is taken!<br>
  Please help!</p>