Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Adding info to mysql database with JSP

  • 07-02-2006 02:28PM
    #1
    Registered Users, Registered Users 2 Posts: 488 ✭✭


    Hi, Im trying to add information to the database using a form in JSP..Im getting the following error when i try to load the jsp page on the tomcat server

    The error is:

    org.apache.jasper.JasperException: /index.jsp(12,24) Unterminated <c:if tag


    This is my code..
    <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
    <%@ taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>
    
    <sql:setDataSource var = "datasource"
    driver = "com.mysql.jdbc.Driver"
    url = "jdbc:mysql://localhost/jspod"
    user = "root" password = "secret" />
    
    <c:if test="${param.title != null}">
    <sql:update dataSource="${datasource}">
    INSERT INTO subs(ID,subname,subURL,subGenre,subRating) VALUES(?, ?, ?, ?, ?)
    <sql:param value="$(param.ID)" />
    <sql:param value="${param.subname)"/>
    <sql:param value="$(param.subURL)" />
    <sql:param value="${param.subGenre)"/>
    <sql:param value="$(param.subRating)"/>
    </sql:update>
    </c:if>
    
    <sql:query var = "subs" dataSource = "$(datasource)">
    SELECT ID,subname,suburl,subgenre,subrating from subs
    </sql:query>
    <html>
    <head>
    <title> A FIRST JSP DATABASE </title>
    </head>
    <body>
    <form method = "post">
    <table border = "1">
    <tr>
    <td>ID</tr><td>subname</tr><td>subURL</tr><td>subGenre</tr><td>subRating</tr>
    </tr>
    <c:forEach var = "row" items= "${subs.rows}">
    <tr>
    <td><c:out value = "${row.ID}" /></td>
    <td><c:out value = "${row.subname}" /></td>
    <td><c:out value = "${row.subURL}" /></td>
    <td><c:out value = "${row.subGenre}" /></td>
    <td><c:out value = "${row.subRating}" /></td>
    </tr>
    </c:forEach>
    <tr>
    <td>&nbsp:</td>
    <td><input type = "text" name = "subname" size = "30" /></td>
    <td><input type = "text" name = "subURL" size = "30"/></td>
    <td><input type = "text" name = "subGenre" size = "30" /></td>
    <td><input type = "text" name = "subRating" size = "30"/></td>
    </tr>
    <tr>
    <td colapse = "3" align = "centre">
    <input type = "Submit" value = "Save new sun"/>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    


Comments

Advertisement