*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jstl error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jstl error" Watch "jstl error" New topic
Author

jstl error

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
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.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Which version of JSTL are you using ?


[My Blog]
All roads lead to JavaRanch
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
Now I get the following message.
/ch23sum10.jsp(20,14) quote symbol expected
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
I've copied the jstl.jar after downloading Tomcat 5.
So I expect it to be jstl1.1
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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

Joined: Apr 01, 2003
Posts: 120
Hello Gautam,
If you see my step 1, that's what i've done.
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
Sorry Gaurav,
I misspelt your name.
I am getting the error still.
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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

Joined: Apr 01, 2003
Posts: 120
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Apr 01, 2003
Posts: 120
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

Joined: Mar 04, 2006
Posts: 254
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Mar 04, 2006
Posts: 254
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Remove the taglib declaration in web.xml.
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Mar 04, 2006
Posts: 254
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
 
Consider Paul's rocket mass heater.
 
subject: jstl error
 
Similar Threads
Problem using core tags
jstl problems
Problem with JSTL sql library in JSP
exception in jstl
simple JSTL problem