0

The following code is a part of my project and the output of this code is that i get all the title of the posts in the database and a delete hyperlink in front of all enteries now when i click delete for a respective title it should be deleted from jsp page how to write code for this? For better understanding i have attached a screen shot also.

<label><h3>
                            Post published:
                        </h3></label>
                        <%
                                    rs = stmt.executeQuery("select title from Postdata");
                        %>

                    <table id="rounded-corner" summary="all posts">
                        <thead>
                            <tr>

                            </tr>
                        </thead>
                        <tfoot>

                        </tfoot>
                        <tbody>
                            <% while (rs.next()) {%>
                            <tr>
                                <td>
                                    <%=rs.getString(1)%>
                                </td>
                                <td>

                                    <a href><%=""%>Delete</a>
                                </td>
                            </tr>
                            <%}%>
                        </tbody>
                    </table>

Edited by katyanni_27: n/a

Attachments Untitled.png 9.08 KB
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Don't use scriptlets. You should choose to use the JSTL and EL. The use of scriptlets is officially discouraged since JSP 2.0 and the birth of taglibs.

As per your requirement, you need to embed title (column) value at href attribute of each anchor tag.

<%
 String paraction=request.getParameter("action");
 String paratitle=request.getParameter("title");

 if(paraction!=null)
  {
     //put deletion code here
   }
%>


 <% while (rs.next()) {
    String title=rs.getString(1);
   %>
  <tr>
    <td><%=title%></td>
    <td><a href="page.jsp?action=delete&title=<%=title%">Delete</a></td>
 </tr>
....

Edited by __avd: typo.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.