wood burning stoves 2.0*
The moose likes JSP and the fly likes Default JSTL URI can't be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Default JSTL URI can Watch "Default JSTL URI can New topic
Author

Default JSTL URI can't be resolved

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I have the following as the first line of my JSP:

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


When I access the page I get the following error message from Tomcat:

The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application


Can anyone suggest what I can do to get around this?

Thanks in advance!


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

What version of the JSTL and Tomcat?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I'm using Tomcat 5.5.

I'm not sure of the JSTL version I need, but I want to use the following code in my JSP:

<c:forEach items="${model.product}"
var="item">
<TR>
<TD><c ut value="${item.symbol}"/></TD>
<TD><c ut value="${item.price}"/></TD>
<TD><c ut value="${item.quantity}"/></TD>
</TR>
</c:forEach>


Thanks...


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

With Tomcat 5, which is a JSP 2.0 container, you need JSTL 1.1.

The URI you gave was a JSTL 1.0 URI.

The appropriate URI would be http://java.sun.com/jsp/jstl/core

Be sure that the appropriate JSTL jar files (jstl.jar and standard.jar) are in WEB-INF/lib.
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
Thanks Bear. Unfortunately I still have the unresolved JSTL URI problem. I am experiencing other weird voodoo with Tomcat so perhaps I have a deeper problem. I will make a separate posting or two outlining the other problems, hopefully someone can tell me what is going on and that will fix this problem as a side effect. I'm using a fresh vanilla install of the latest version of Tomcat on Windows XP, with no custom configurations, so I'm clueless as to why I am having so much trouble. I am having trouble 1) with redeployment of WAR files not being exploded correctly under the $TOMCAT_HOME/webapps directory (I'm running Ant war and copy tasks from within Eclipse), and 2) with an old, nonexistent version of a JSP page *sometimes* being displayed instead of the current JSP page which is used as the view by my Spring MVC application (I have cleared the cache of the browser but this doesn't help). Furthermore when I kill Tomcat and start it again the Tomcat manager shows active sessions for the application, which maybe has something to do with the problem #2 above. How any of this relates to the problem of not being able to resolve the JSTL URI is not clear to me, but hopefully I'll be able to find out and I'll update this thread with the information.


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

I can't comment on your other issues (please be sure to post Tomcat-specific questions in the Tomcat forum) without more info, but with regards to the JSTL:

1) Where did you get your JSTL 1.1 implementation?

2) Are the two jar files in WEB-INF/lib?
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
The jstl.jar and standard.jar came from spring-framework-1.2.3-with-dependencies.zip, and both are included in the WEB-INF/lib directory.

I have posted a question to the Tomcat group here


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The jstl.jar and standard.jar came from


Check that these are a JSTL 1.1 implementation. A means to perform a direct check would be to open up standard.jar, find and open c.tld and check its URI.
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
It turns out that these libraries which come with Spring are JSTL 1.0. I changed the URI back to the JSTL 1.0 version and now all works as advertised.

I think my original problem was that I was using the correct JSTL 1.0 URI and had jstl.jar in WEB-INF/lib, but I didn't have standard.jar in WEB-INF/lib.

Thanks for your help!


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

You will run into compatibility issues using JSTL 1.0 with a JSP 2.0 container. My advice is to replace the jars with the JSTL 1.1 jars asap.
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
Thanks Bear, will do.

--James
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
Something odd happens when I use the JSTL 1.1 implementations from Jakarta (jakarta-taglibs-standard-1.1.2.zip). Whereas before (using the JSTL 1.0 URI and the implementations found in the Spring distribution) I would get values displayed in my table as expected. Now what I see is the actual code displayed, i.e. ${item.price} instead of 47.00, for example. However when I go back to using the JSTL 1.0 URI but still use the the JSTL 1.1 implementations in my WEB-INF/lib I get the proper behavior, i.e. I see the actual values instead of the code strings. Does this make any sense?

BTW my JSP code looks like this:



--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Are you using the correct JSTL 1.1 URI?

Is your web app declared as a Servlet 2.4 web app in the web.xml? (which, in Tomcat enables the EL)
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
The URI I use for JSTL 1.1 is http://java.sun.com/jsp/jstl/core

The URI I use for JSTL 1.0 is http://java.sun.com/jstl/core

How would I specify that my application uses Servlet 2.4 in web.xml? Is this required for JSTL 1.1?

Do I not want to have EL processing performed on my JSPs? Do you suspect that an initial EL evaluation is what is causing the problem?


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

To declare the web app as a 2.4-conformant app, the web.xml should be:



This will tell Tomcat to turn on the EL processing and other JSP 2.0 type "Stuff".
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
When I add that to my web.xml I get the same problem as before when using the JSTL 1.1 URI -- I see the code and not the values. I think I'll just stick with using the JSTL 1.0 URI since the JSTL tags are working as advertised when I use that.


--James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

You've clearly got some versioning issues. You can try to stick with JSTL 1.0, but I can guarentee you'll run into trouble.

Have you tried making sure that template text EL expressions are evaluated completely outside of the JSTL?

Something simple like:

<p>3 + 4 = ${3 + 4}</p>

in the body.

If this isn't working. Your app isn't set up correctly
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
What's very strange is that this is working for me now, sometimes. If I change the web.xml to Servlet 2.4 and then the JSTL URI back to 1.0 I can get the code and not the values, and then change the URI back to 1.1 and still only see the code. I went back abnd forth with several combinations and finally it is working as advertised again using Servlet 2.4 in the web.xml and JSTL 1.1 URI in the JSP. I think there is something weird going on with my installation of Tomcat, as it appears to be caching pages, or maybe the browser is not refreshing each time as it should. Honestly, I'm not doing anything fishy with my Tomcat, and this is the only application running on it. I never expected it would be so complicated just to use a simple JSTL loop tag. In any event I will stay with the Servlet 2.4 setting in web.xml and the JSTL 1.1 URI in my JSP pages, hopefully things will continue to work as they should if I don't muck around with these settings again.

Thanks again for your help with this problem.


--James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default JSTL URI can't be resolved
 
Similar Threads
JSTL Core Library Error
The absolute uri problem
JSTL URI Problem
What is the URI for JSTL?
JSTL Error cannot be resolved