-1

hi i want to get book names from database in jsp page i am getting all book names but my requirment is i want to update selected books by checkbox so how can i get only selected books in next page...

here is my jsp code...Thanks in advance.

<form action="book1.jsp" name="f1">
    <table border="1" align="center">
        <caption>Select Book for Update</caption>
        <%  
            while(rs.next())
            {
         %>
        <tr>
            <th colspan="2">Book name</th>           
            <td><%= rs.getString("bookname") %></td>
            <td> <input type="checkbox" value="${row.id}" name="b1"/> </td>
        <% } %>
        </tr>       
        <tr>
            <td colspan="3"><input type="submit" value="Update" ></td>
        </tr>
    </table>        

Arun Sudhakaran
  • 2,167
  • 4
  • 27
  • 52
Govind
  • 1
  • 1
  • 1
    Possible duplicate of [How to get checked checkboxes in JSP](https://stackoverflow.com/questions/12396828/how-to-get-checked-checkboxes-in-jsp) – Yash Nov 23 '17 at 06:38

1 Answers1

0
<%! String[] books; 
books = request.getParameterValues("b1");
if (books != null) 
{
  for (int i = 0; i < books.length; i++) 
  {
     out.println ("<b>"+books[i]+"<b>");
  }
}
else out.println ("<b>none<b>");
%>
sasikumar
  • 12,540
  • 3
  • 28
  • 48