You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2010/05/07 16:39:35 UTC

TC 6 & JSTL: attribute does not accept any expressions

All,

I'm a complete newbie to JSTL and I'm having trouble getting a simple 
page to render. The page below gives me the error:

org.apache.jasper.JasperException: /tasks.jsp(18,6) According to TLD or 
attribute directive in tag file, attribute items does not accept any 
expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
[...]

It seems to me that "items" had better be an expression.

I have a fresh install of Tomcat 6.0.26 running on Sun's 1.6.0-_20-b02 
JVM on 32-bit Linux. I downloaded the JSTL "api" and "impl" packages 
from https://jstl.dev.java.net/download.html and put the JAR files 
directly into WEB-INF/lib.

<%@ page
   pageEncoding="UTF-8"
   import="lj.timesheet.Task"
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
   <head>
     <title>My Tasks</title>
   </head>

   <body>
     <h1>My Tasks</h1>

     <table>
       <tr>
	<th>Description</th>
       </tr>
       <c:forEach var="task" items="${tasks}">
	<tr>
	  <td><c:out value="${task.description}" /></td>
	</tr>
       </c:forEach>
     </table>
   </body>
</html>

I had this problem on my Linux desktop which I then rebooted back into 
Windows to write this message. Just for kicks, I tossed this JSP onto my 
dev server for work (and removed the reference to the Task class) and it 
worked no problem.

The differences I can see between these environments are:
1. No "Task" import in the environment where it works
2. Direct call to the JSP in the environment where it works
    (rather than calling a servlet which forwards to it)
3. Slightly different Java version (it's 1.6.0-12 in the
    working environment)
4. Working environment is using CATALINA_BASE to run Tomcat from
    a separate directory than the actual distro


Can anyone shed any light on this? I'm going to toss my entire WAR file 
into the environment where it /is/ working to see if it's some 
interaction problem.

Thanks,
-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TC 6 & JSTL: attribute does not accept any expressions

Posted by Pid <pi...@pidster.com>.
On 07/05/2010 15:57, Christopher Schultz wrote:
> All,
> 
> On 05/07/2010 10:39 AM, Christopher Schultz wrote:
>> Can anyone shed any light on this? I'm going to toss my entire WAR file
>> into the environment where it /is/ working to see if it's some
>> interaction problem.
> 
> Placing my entire WAR file into the environment where I could get the
> JSP working results in the same error (full stack trace this time, just
> in case it's relevant):
> 
> org.apache.jasper.JasperException: /tasks.jsp(18,6) According to TLD or
> attribute directive in tag file, attribute items does not accept any
> expressions

Find the TLD that it's referencing and look at the 'items' attribute.
If it says rtexprvalue="false" it's wrong.  If it says 'true' then we're
looking in the wrong place.


p


> 	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
> 	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
> 	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
> 	org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1209)
> 	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846)
> 	org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
> 	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
> 	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
> 	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
> 	org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
> 	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
> 	org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
> 	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
> 	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> 	lj.timesheet.GetTasksServlet.doGet(GetTasksServlet.java:29)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> 
> Basically, my servlet creates a List of Task objects and puts them into
> a request attribute called "tasks", then does:
> 
> 	getServletContext().getRequestDispatcher("/tasks.jsp")
> 	    .forward(request, response);
> 
> This is pretty simple stuff: what am I missing?
> 
> Thanks,
> -chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



Re: TC 6 & JSTL: attribute does not accept any expressions

Posted by Christopher Schultz <ch...@christopherschultz.net>.
All,

On 05/07/2010 10:39 AM, Christopher Schultz wrote:
> Can anyone shed any light on this? I'm going to toss my entire WAR file
> into the environment where it /is/ working to see if it's some
> interaction problem.

Placing my entire WAR file into the environment where I could get the
JSP working results in the same error (full stack trace this time, just
in case it's relevant):

org.apache.jasper.JasperException: /tasks.jsp(18,6) According to TLD or
attribute directive in tag file, attribute items does not accept any
expressions
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
	org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1209)
	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846)
	org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
	org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	lj.timesheet.GetTasksServlet.doGet(GetTasksServlet.java:29)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Basically, my servlet creates a List of Task objects and puts them into
a request attribute called "tasks", then does:

	getServletContext().getRequestDispatcher("/tasks.jsp")
	    .forward(request, response);

This is pretty simple stuff: what am I missing?

Thanks,
-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TC 6 & JSTL: attribute does not accept any expressions

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kris,

On 5/7/2010 11:12 AM, Kris Schneider wrote:
> On Fri, May 7, 2010 at 10:39 AM, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>>
>> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
> 
> The correct core taglib uri for JSTL 1.2 is: http://java.sun.com/jsp/jstl/core

Thanks a /ton/: that was the whole problem.

> Also make sure you're using a Servlet 2.5 web.xml.

Yep, my web.xml says:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

It just looks like I had the wrong tablib URI. Inspecting the tag
library JAR files, I can see that these two URIs are valid:

JSTL 1.0: http://java.sun.com/jstl/core
JSTL 1.2: http://java.sun.com/jsp/jstl/core

Apparently, the 1.0 version doesn't allow EL expressions (and presumably
must operate directly on a named page/request attribute).

Switching to the 1.2 tag library URI did the trick.

Thanks a lot!

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvkr8kACgkQ9CaO5/Lv0PB6KwCgp4Li0J0khXVQiD88+EDkE1qp
6fIAoIyU+3dkKqLo+kHOrDIPRlOKop0Y
=HPBr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TC 6 & JSTL: attribute does not accept any expressions

Posted by Kris Schneider <ks...@gmail.com>.
On Fri, May 7, 2010 at 10:39 AM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> All,
>
> I'm a complete newbie to JSTL and I'm having trouble getting a simple page
> to render. The page below gives me the error:
>
> org.apache.jasper.JasperException: /tasks.jsp(18,6) According to TLD or
> attribute directive in tag file, attribute items does not accept any
> expressions
> org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
> org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
> [...]
>
> It seems to me that "items" had better be an expression.
>
> I have a fresh install of Tomcat 6.0.26 running on Sun's 1.6.0-_20-b02 JVM
> on 32-bit Linux. I downloaded the JSTL "api" and "impl" packages from
> https://jstl.dev.java.net/download.html and put the JAR files directly into
> WEB-INF/lib.
>
> <%@ page
>  pageEncoding="UTF-8"
>  import="lj.timesheet.Task"
> %>
> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

The correct core taglib uri for JSTL 1.2 is: http://java.sun.com/jsp/jstl/core

Also make sure you're using a Servlet 2.5 web.xml.

> <html>
>  <head>
>    <title>My Tasks</title>
>  </head>
>
>  <body>
>    <h1>My Tasks</h1>
>
>    <table>
>      <tr>
>        <th>Description</th>
>      </tr>
>      <c:forEach var="task" items="${tasks}">
>        <tr>
>          <td><c:out value="${task.description}" /></td>
>        </tr>
>      </c:forEach>
>    </table>
>  </body>
> </html>
>
> I had this problem on my Linux desktop which I then rebooted back into
> Windows to write this message. Just for kicks, I tossed this JSP onto my dev
> server for work (and removed the reference to the Task class) and it worked
> no problem.
>
> The differences I can see between these environments are:
> 1. No "Task" import in the environment where it works
> 2. Direct call to the JSP in the environment where it works
>   (rather than calling a servlet which forwards to it)
> 3. Slightly different Java version (it's 1.6.0-12 in the
>   working environment)
> 4. Working environment is using CATALINA_BASE to run Tomcat from
>   a separate directory than the actual distro
>
>
> Can anyone shed any light on this? I'm going to toss my entire WAR file into
> the environment where it /is/ working to see if it's some interaction
> problem.
>
> Thanks,
> -chris

-- 
Kris Schneider

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org