SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: JSP el

  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JSP el

    I am trying some simple code at first to learn a little of the new expression language. However I am already getting an error:
    Here's the test page, I found this on google, on some jsp tutorials. I changed the db connection to my db.
    Code:
    <&#37;@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    
    
    
    <sql:setDataSource var="dataSource" driver="com.mysql.jdbc.Driver"
    	url="jdbc:mysql://localhost:3306/petback2" user="root" password="sa"
    	/>
    <html>
    <body>
    
    <sql:setDataSource
    url="jdbc:mysql://localhost/petback2"
    driver="com.mysql.jdbc.Driver"
    user="root"
    password="xxxxxxxx" />
    
    
    
    
    <sql:query var="user"
               sql="Select ownerid,oname,ostreet from powners">
    </sql:query>
    
    <table border=1>
    
    
    <c:forEach var="row" items="${user.row}">
    THIS ABOVE LINE HAS ERROR
    <tr>
    <td><c:out value="${row.ownerid}"/></td>
    <td><c:out value="${row.oname}"/></td>
    <td><c:out value="${row.ostreet}"/></td>
    </tr>
    </c:forEach>
    </table>
    </body>
    </html>
    The error says: According to TLD or attribute directive in tag file, attribute items does not accept any expressions
    Can someone help?

  2. #2
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found answer, had wrong tag library, correct ones are

    <&#37;@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    Hope this can help someone. These are for:
    Servlets 2.4, JSP 2.0, JSTL 1.1

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,399
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is bit off topic but relates to JSP EL. When you look into JSF 2.X, they are completely replacing JSP EL. Just FYI, JSF 2.X spec is created by Java Community themselves. So, you may have to learn a whole new JSF expression language. They both look very identical but slightly different.


Bookmarks

Posting Permissions

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