Results 1 to 17 of 17

Thread: Unbalanced JSTL <sql:update> tag?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved Unbalanced JSTL <sql:update> tag?

    Tomcat says unbalanced end tag. Im not quite sure what the problem is though. Perhaps the problem is the SQL itself. Does anything look wrong?
    Code:
     <sql:update>
        UPDATE Employees
         SET fname = ?,
         lname = ?,
         phonenum = ?,
         WHERE empid = ?
         <sql:param value = "${param.fname}"/>
         <sql:param value = "${param.lname}"/>
         <sql:param value = "${param.phonenum}"/>
         <sql:param value = "${param.empid}"/>
     </sql:update>

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Unbalanced JSTL <sql:update> tag?

    I don't know much about this tomcat stuff, but I do know that the unbalanced tag means there's usually an ending tag missing. It looks like you have one though. Do you think there is suppose to be a starting and ending tag for this:
    Code:
    <likesomethinghere>
     <sql:param value = "${param.fname}"/>
         <sql:param value = "${param.lname}"/>
         <sql:param value = "${param.phonenum}"/>
         <sql:param value = "${param.empid}"/>
    </andsomecraphere>
    I don't know what I'm talking about. This is just a suggestion, so it's probably wrong.

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Posted by System_Error

    I don't know what I'm talking about. This is just a suggestion, so it's probably wrong
    Don't worry if you are unsure. All suggestions help.

    At first i thought the problem might be with the ,'s in my sql statement but that dosen't seem to be the problem. The only <sql:update> </sql:update> tags i have are below. They are both contained in JSTL conditional processing tags so don't know if that might be the problem. I don't see why the placement of the following blocks would generate that tomcat error though.
    Code:
     <sql:update>
       INSERT INTO Employees 
       (empid,fname,lname,phonenum)
       values(?,?,?,?)
       <sql:param value = "${param.empid}"/>
       <sql:param value = "${param.fname}"/>
       <sql:param value = "${param.lname}"/>
       <sql:param value = "${param.phonenum}"/>
     </sql:update>
    
     <sql:update>
       UPDATE Employees
       SET fname = ?,
       lname = ?,
       phonenum = ?,
       WHERE empid = ?
       <sql:param value = "${param.fname}"/>
       <sql:param value = "${param.lname}"/>
       <sql:param value = "${param.phonenum}"/>
       <sql:param value = "${param.empid}"/>
     </sql:update>

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Unbalanced JSTL <sql:update> tag?

    It might be a tag in the surroundings.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Here's the exact message that tomcat spits out. org.apache.jasper.JasperException: /EmployeeSearch.jsp(162,4) The end tag "&lt;/sql:update" is unbalanced

    <sql:update> is supposed to be used with queries that return 0 rows like UDATE , INSERT and DDL like CREATE TABLE so i don't think that i have to nest any <sql:query> tags inside of the update tags. I thought the problem might be that at first.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Unbalanced JSTL <sql:update> tag?

    Can you give a little more code around the unbalanced tag? Especially the next outer tags.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Ill just post the whole thing.
    Code:
     <%@ page contentType="text/html" %>
     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
     <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
      
     <html>
      <head>
       <title> Employee Search </title>
      </head>
      <body bgcolor = "black">
      <form action="EmployeeSearch.jsp" method="get">
      <table>
       <tr>
        <td>
         <font color = "blue">
          Plese enter an employee id to perform a search
         </font>
        </td>
        <td>
         <font color = "blue">
          Employee ID:
         </font>
         <input type = "text" name = "empid"/>
        </td>
       </tr>
      <tr>
       <td>
        <input type = "subbmit" name = "Search"/>
       </td>
      </tr>
     </table>
    
      <%-- create the database table --%>
       <sql:update>
        CREATE TABLE Employees(
         empid char(5) PRIMARY KEY,
         fname varchar(20),
         lname varchar(25), 
         phonenum varchar(10),
         );
      </sql:update>
      
       
       <sql:query var="empDbInfo">
        SELECT * from Employees Where empid = ?
        <sql:param value = "${param.empid}"/>
       </sql:query>
     
      <%-- search for emp on empid --%>
      <%-- first run this will execute since table was just created --%>
       <c:choose>
        <c:when test = "${empDbInfo.rowCount == 0}">
         <%-- if 0 rows are returned then employee does not exist in the database --%>
         <%-- dynamically create the html elements so the user can supply the employee information--%>
        <table>
         <tr>
          <td>
           <font color = "blue">
            Employee dosent exist please add him in
           </font>
          </td>
         </tr>
        <tr>
         <td>
          <font color = "blue">
           Employee ID:
          </font>
          <input type = "text" name = "empid"/>
         </td>
        </tr>
       <tr>
         <td>
          <font color = "blue">
           First Name:
          </font>
          <input type = "text" name = "fname"/>
         </td>
        </tr>
       <tr>
         <td>
          <font color = "blue">
           Last Name:
          </font>
          <input type = "text" name = "lname"/>
         </td>
        </tr>
       <tr>
        <td>
          <font color = "blue">
          Phone Number:
          </font>
          <input type = "text" name = "phonenum"/>
         </td>
        </tr>
       <tr>
        <td>
         <input type = "subbmit" name = "Add Employee Data"/>
        </td>
      </tr>
       </table>
         <sql:update>
          INSERT INTO Employees 
          (empid,fname,lname,phonenum)
          values(?,?,?,?)
          <sql:param value = "${param.empid}"/>
          <sql:param value = "${param.fname}"/>
          <sql:param value = "${param.lname}"/>
          <sql:param value = "${param.phonenum}"/>
         </sql:update> 
        
        </c:when>
        <c:otherwise>
         <%-- one row returned so employee exists --%>
        <table>
         <tr>
          <td>
           <font color = "blue">
            Employee found. If you want to update employee information then go ahead
           </font>
          </td>
          </tr>
          <tr>
         <td>
          <font color = "blue">
           Employee ID:
          </font>
          <input type = "text" name = "empid"/>
         </td>
        </tr>
         <tr>
          <td>
           <font color = "blue">
            First Name:
           </font>
          <input type = "text" name = "fname"/>
          </td>
         </tr>
         <tr>
          <td>
           <font color = "blue">
            Last Name:
           </font>
           <input type = "text" name = "lname"/>
          </td>
         </tr>
         <tr>
          <td>
           <font color = "blue">
            Phone Number:
           </font>
          <input type = "text" name = "phonenum"/>
          </td>
         </tr>
         <tr>
          <td>
          <input type = "subbmit" name = "Update or get Employee Data"/>
          </td>
         </tr>
       <sql:update>
        UPDATE Employees
         SET fname = ?,
         lname = ?,
         phonenum = ?
         WHERE empid = ?
         <sql:param value = "${param.fname}"/>
         <sql:param value = "${param.lname}"/>
         <sql:param value = "${param.phonenum}"/>
         <sql:param value = "${param.empid}"/>
        </sql:update>
        <%-- output db data --%>
        <sql:query var = "dbdata">
         SELECT * FROM Employees
          WHERE empid = ?
         <sql:param value = "${param.empid}"/>
        </sql:query>
          <table>
           <tr>
            <c:forEach items="${dbdata.columnNames}" var="colName">
             <th>${fn:escapeXml(colName)}</th>
            </c:forEach>
           </tr>
            <c:forEach items="${empList.rowsByIndex}" var="row">
           <tr>
            <c:forEach items="${row}" var="column">
             <td>${fn:escapeXml(column)}</td>
            </c:forEach>
           </tr>
           </c:forEach>
          </table>
        </c:otherwise>
       </c:choose>
      </form>
     </body>
    </html>

  8. #8
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Unbalanced JSTL <sql:update> tag?

    Wow. It's pretty.

  9. #9

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Yeah i get obsessed about expression and tag placement. Some are still off though.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Unbalanced JSTL <sql:update> tag?

    I found a typo in this input's type attribute, but nothing else. Sorry.
    <input type = "subbmit" name = "Update or get Employee Data"/>
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Unbalanced JSTL <sql:update> tag?

    If you or C.B. can't find anything wrong, then could it possibly be something's up with SQL or tomcat? I know in my jdk I get some really weird errors while doing applets and having paint methods. It will show up error's on statements not even in my program!! So could something like this be going on?

  12. #12

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    I fixed the typo and added in a page directive <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>. Now i am having some driver issues but nothing i shouldn't be able to fix. Hopefully i will get this working today. Thanks for all the help guys.

  13. #13

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    For some reason jasper keeps looking in the WEB-INF/web.xml for all of the driver information when i have already supplied the driver info in the .jsp page itself.

    javax.servlet.ServletException: javax.servlet.jsp.JspTagException: In &lt;driver&gt;, invalid driver class name: "java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver"

    Unless it is looking in the proper order (page, request, session and application scope, and finally the context parameter) and i just have the <sql:setDataSource> tag coded wrong.

  14. #14

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Hummm. I moved the mysql-connector-java-3.16-bin.jar file from the C:\jre1.5.0\lib\ext directory to the C:\Jakarta\jakarta-tomcat-5.0.28\webapps\ora\WEB-INF\lib which is the dir where the JConnector docs say it should be. I scrapped the code in the .jsp page that sets the data source and i just changed the web.xml but no luck yet.

    Here's the part of the web.xml file that sets the driver and data source. Does anything look wrong?
    Code:
    <!-- Used by the JSTL database actions -->
      <context-param>
        <param-name>
          javax.servlet.jsp.jstl.sql.dataSource
        </param-name>
        <param-value>
         jdbc:mysql://localhost:8080/test,com.mysql.jdbc.Driver
        </param-value>
      </context-param>

  15. #15

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Yup port has to be 3306 not 8080.
    Code:
    <!-- Used by the JSTL database actions -->
      <context-param>
        <param-name>
          javax.servlet.jsp.jstl.sql.dataSource
        </param-name>
        <param-value>
         jdbc:mysql://localhost:3306/test,com.mysql.jdbc.Driver
        </param-value>
      </context-param>

  16. #16

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Unbalanced JSTL <sql:update> tag?

    Ok getting closer but now i have some SQL issues.

    javax.servlet.ServletException: javax.servlet.jsp.JspException:
    INSERT INTO Employees
    (empid,fname,lname,phonenum)
    values(?,?,?,?)

    Column 'empid' cannot be null

    I don't know if this has anything to do with the empid being a primary key.
    Code:
    <%-- create the database table --%>
       <sql:update>
        CREATE TABLE Employees(
         empid char(5) PRIMARY KEY,
         fname varchar(20),
         lname varchar(25), 
         phonenum varchar(10)
         );
      </sql:update>

  17. #17
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Unbalanced JSTL <sql:update> tag?

    Yeah, it has. Apparently, no value gets assigned to the parameter, so the driver attempts to set the column to null, which is not permitted for a primary key.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width