• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)?
 
Sammy Bill
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the <s:> tags? My guess is those are the issue. Are they JSP 2.0 compatible?
 
Sammy Bill
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should have mentioned that first off. I've moved this to the Struts forum where the Struts-savvy hang out.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic