• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jstl error

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I have copied the jstl.jar file from tomcat\webapps\jsp-examples\WEB-INF\lib\jstl.jar
to C:\tomcat\webapps\AllTopics\WEB-INF\lib.

2. When I run the jsp file, I get the following
message.
According to TLD or attribute directive in tag file, attribute test does not accept any expressions

3. The follwing code is used.
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<html>
<head><title>Accessing a Scoped Value</title></head>
<body bgcolor="#FDF5E6" text="FF00FF">

<h2>Hello


<c:choose>

<c:when test="${empty param.userName}">
Esteemed Visitor
</c:when>

<c therwise>

<c ut value="${param.userName}" />

</c therwise>

</c:choose>
</h2>
</body>
</html>

Why the error message results.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which version of JSTL are you using ?
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I get the following message.
/ch23sum10.jsp(20,14) quote symbol expected
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've copied the jstl.jar after downloading Tomcat 5.
So I expect it to be jstl1.1
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sunder

I have checked out the code and even tried on my machine its perfect and will give result Hello Esteemed Visitor, only thing you need to do is to copy both jstl.jar and standard.jar from
Tomcat 5.0\webapps\jsp-examples\WEB-INF\lib

to

Tomcat 5.0\webapps\your_app_Name\WEB-INF\lib

Regards
Gaurav
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Gautam,
If you see my step 1, that's what i've done.
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Gaurav,
I misspelt your name.
I am getting the error still.
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Sunder before posting the message I read your message but as per the message you copied only jltl.jar but not mentioned anything about standard.jar, if you will not have both jar files it will give translation time errors.
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have both jstl.jar & standard.jar in the lib directory.
Another funny thing that is happening is I used one of the jstl
examples available in Tomcat directory and it works well.
I just do not know what is wrong with this code.
I even deleted the entire file and re punched the whole thing.
Still the problem persists.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
instead of
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

I think that your URI is for a previous version of JSTL.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to understand the difference, look into standard.jar/META-INF.

c.tld -> <uri>http://java.sun.com/jsp/jstl/core</uri>;
c-1_0.tld -> <uri>http://java.sun.com/jstl/core</uri>;

So using http://java.sun.com/jstl/core as a TLD URI will point to the old version(1.0).
In 1.0, the "test" attribute of the "when" tag does not accept expressions.
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Satou.

It is the mistake. I started checking each and every character when I
realized the mistake. I spent nearly a day for this.
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So using http://java.sun.com/jstl/core as a TLD URI will point to the old version(1.0).
In 1.0, the "test" attribute of the "when" tag does not accept expressions.

Then, how come it worked on my machine.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you declare a TLD in your web.xml ?

By the way, there was a page at the ranch :
http://faq.javaranch.com/view?JstlTagLibDefinitions
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to check the things again, do you think its necessary to declare it in web.xml file

as the above code is working fine on my machine if I choose either

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

or

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

So what would be done to make sure its not working with older version
i.e is we specify
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

what values to specify for <taglib-uri> , <taglib-location> in web.xml
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what values to specify for <taglib-uri> , <taglib-location> in web.xml


Remove the taglib declaration in web.xml.
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not defined ,I am asking If we need that, as to my knowledge, no need of taglib in case of standard tags
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, no need to define it in web.xml.
Don't know why the old tag version works for you.
My guess is that the old URI is redefined somewhere else. Did you check standard.jar's TLDs ?
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also donot know why its working,
If things are not working then its a problem, but here the things are working.
Any how Sunder's problem solved , mine is already working.
Leave the discussion here
and
Thanks alot
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic