File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes According to TLD or attribute directive in tag file, attribute value does not accept any expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "According to TLD or attribute directive in tag file, attribute value does not accept any expressions" Watch "According to TLD or attribute directive in tag file, attribute value does not accept any expressions" New topic
Author

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Sammy Bill
Ranch Hand

Joined: Dec 29, 2008
Posts: 96
Hello, i m
trying to put an EL expression inside a value attribute and i m getting the following exception.

org.apache.jasper.JasperException: /products.jsp(16,17) According to TLD or attribute directive in tag file, attribute value does not accept any expressions

here is the whole jsp file.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>

<title>Products</title>
</head>
<body>
<s:actionerror />
<c:forEach var="product" items="${requestScope.catalog}" >
Product: <s:label name="productId" value="${product.productID}"></s:label>

Description: ${product.description}

Quantity available: ${product.quantity}

Unit Price: ${product.unitPrice}
<s:form method="POST">
<s:textfield name="quantity" size="3"></s:textfield>
<s:submit value="add to cart"></s:submit>
</s:form>
</c:forEach>

</body>
</html>

I m using jsp2.0 and JSTL 1.2 with Tomcat 6.

things i have tried and did not work:
1) change the URI from
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
to <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

2)change the jstl.jar with jstl1.2.jar and removing the standard.jar

any other solutions?

Thanks.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Oussama M Billah wrote:1) change the URI from
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
to &lt;%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %&gt;

That just switched you back to JSTL 1.0. No good.

Is your deployment descriptor properly declared using Servlets 2.4 Schema (as described in the JSP FAQ)?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sammy Bill
Ranch Hand

Joined: Dec 29, 2008
Posts: 96
Bear Bibeault wrote:
Oussama M Billah wrote:1) change the URI from
&amp;lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jsp/jstl/core&quot; %&amp;gt;
to &amp;lt;%@ taglib uri=&quot;http://java.sun.com/jstl/core_rt&quot; prefix=&quot;c&quot; %&amp;gt;

That just switched you back to JSTL 1.0. No good.

Is your deployment descriptor properly declared using Servlets 2.4 Schema (as described in the JSP FAQ)?


I did change the declaration on my web.xml to

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

as mentioned in the JSP FAQs. but i still get the same exception.
any other ideas?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Using code tags this time, please post the tag that is causing the issue. The code in your original post is not readable.

Please read this for more information.
Sammy Bill
Ranch Hand

Joined: Dec 29, 2008
Posts: 96
Bear Bibeault wrote:Using code tags this time, please post the tag that is causing the issue. The code in your original post is not readable.

Please read this for more information.


Ok,

let me redo it from beginning with code tags:

here are the information and jar files i m using:

in my web.xml i m having



then i m having jstl-1.2.jar in my lib directory
then in my jsp i m having the following taglib declaration



then in the following jsp code



i m getting org.apache.jasper.JasperException: /products.jsp(16,17) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
in the second line in the previous code where i m using value="${product.productID}"

I followed the steps in the JSP FAQs but i could not solve it.
Please advice.

Thanks a lot for your time.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

What are the <s:> tags? My guess is those are the issue. Are they JSP 2.0 compatible?
Sammy Bill
Ranch Hand

Joined: Dec 29, 2008
Posts: 96
Bear Bibeault wrote:What are the &lt;s:&gt; tags? My guess is those are the issue. Are they JSP 2.0 compatible?


they are struts 2 tags

i m declaring them in

<%@ taglib prefix="s" uri="/struts-tags"%>

For some reasons when i remove those tags it just works fine!!!

how can i make sure if they are compatibe with JSP 2.0?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

You should have mentioned that first off. I've moved this to the Struts forum where the Struts-savvy hang out.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's not that they're "incompatible" with JSP 2.0, it's that we don't allow JSP EL expressions in their attributes to avoid a security issue.

Some people just extract the TLD, remove the restriction, and either use that TLD or re-jar it back up. Or, in your case, just use <s:iterator> and skip the JSTL tags, or make sure <c:foreach> puts the iterated value into one of the normal JEE scopes and use an OGNL expression, which will check the scopes as well.
tibi stibi
Greenhorn

Joined: May 26, 2008
Posts: 2
David Newton wrote:It's not that they're "incompatible" with JSP 2.0, it's that we don't allow JSP EL expressions in their attributes to avoid a security issue.

Some people just extract the TLD, remove the restriction, and either use that TLD or re-jar it back up. Or, in your case, just use <s:iterator> and skip the JSTL tags, or make sure <c:foreach> puts the iterated value into one of the normal JEE scopes and use an OGNL expression, which will check the scopes as well.


could you post an example of the second option?
i have something like this:

which is ok
now i want to devide the value by 100 (its in cents) i was working on something like this but <%=d %> is not allowed.

vikky agrawal
Ranch Hand

Joined: Dec 18, 2008
Posts: 65
Hi,

I am working on a web development project with spring framework. we are using Resin server : resin3.1.12 and having the same issue as above described.
My web.xml file looks like this :


and it is working fine on production server but creating a new project in netbeans and using same code and all other files give me the mentioned error.
I tried the solutions I found on some blogs:
Reference the correct JSTL uri in your JSP,change


It worked and jsp error was removed.. but its not a feasible solution to change this in all jsp files.
and since the code already working fine, then such kind of changes may create problems on production environment.

Anyone having idea from where this error can be removed and what is the root cause for this problem, provide reference if any.!

Thanks!


scjp 6
http://algorithmsea.blogspot.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: According to TLD or attribute directive in tag file, attribute value does not accept any expressions
 
Similar Threads
JSTL: Attribute value does not accept any expressions
Expressions problem
JSTL help please
JasperException with JSTL
According to TLD or attribute directive in tag file, attribute value does not accept any expressions