Newbie: JSTL question, delete record link

Discussion in 'Java' started by Cardinal, Jan 12, 2006.

  1. Cardinal

    Cardinal Guest

    I have a small application that reads and displays book information
    from a database. It also allows the user to add books and their prices.
    It's code is below. I want to add a delete link along side of each book
    that allows the user to delete a book. No confirm message or anything
    like that - I'm just interested in getting it to work. Can anyone give
    me a hint on what JSTL code might accomplish this. If that works then
    I'm sure I can use it to develop an edit link as well. Thanks very

    P.S. This is a modified example from the Beginning JSP 2.0 book by wrox
    but I'm trying to get it to do more to increase my understanding.
    Thanks again.

    <%@ taglib uri="" prefix="c" %>
    <%@ taglib uri="" prefix="sql" %>

    <sql:setDataSource var="datasource" driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/publish" user="publish" password="wrox" />

    <c:if test="${param.title != null}">
    <sql:update dataSource="${datasource}">
    INSERT INTO book (title, price)
    VALUES (?, ?)
    <sql:param value="${param.title}" />
    <sql:param value="${param.price}" />

    <sql:query var="books" dataSource="${datasource}">
    select id, title, price FROM book

    <title>First JSP Database</title>
    font-family:"arial", "verdana";

    <form method="post">
    <table id="reg">
    <c:forEach var="row" items="${books.rows}">
    <td width="10%"><c:eek:ut value="${}" /></td>
    <td><c:eek:ut value="${row.title}" /></td>
    <td width="10%"><c:eek:ut value="${row.price}" /></td>
    <td width="10%">Edit</td>
    <td width="10%">Delete</td>
    <td><input type="Text" name="title" size="30" /></td>
    <td><input type="Text" name="price" size="5" /></td>
    <td colspan="3" align="center">
    <input type="submit" value="Save New Book" />

    Cardinal, Jan 12, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.