aspose file tools*
The moose likes JSP and the fly likes JSTL problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL problem" Watch "JSTL problem" New topic
Author

JSTL problem

Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
I tried to deploy my first Jsp, then the tomcat5.5 throw an Exception. I use tomcat5.5 and jdk1.5, the IDE is eclipse3.1 and MyEclipse. Here is the jsp code.

<%@ page contentType = "text/html" %>
<%@ taglib prefix="c" uri ="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<TITLE> first jsp</TITLE>
</head>
<body bgcolor="blue">
<h1>jsp is easy as...</h1>
<%--Calculate the sum of 1+2+3 dynamically --%>
1+2+3 = <c ut value ="${1+2+3}"/>
</body>
</html>


and here is the error message:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:316)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:147)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs


Can anyone show me what I did wrong? Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Where did you put the jstl.jar and standard.jar files?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
I'm new to jsp. So I have to put jstl.jar and standard jar files in WEB-INF/lib before I use them? where can I download these jar files?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

It's all in the JSP FAQ.
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
I put both jstl.jar and standard.jar files in tomcat /webapps/MyProjectname/WEB-INF/lib, and it still doesn't work and get the same error message.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Which version of the JSTL did you download?
Rodrigo Alvarez
Ranch Hand

Joined: Apr 10, 2006
Posts: 75
Hi Phoebe,

Did you include the tag lib descriptor in your directory structure of your web component?

It should be a file name "core.tld" or something and it comes normaly with jstl jars you downloaded.

Typically, you would put it in "WEB-INF/tld/" (although I think any place under WEB-INF is acceptable)

Then, all you have to do is to map the uri of this taglib to the location of that taglib descriptor. You specified the uri there:




So you just have to include something like :





in your DD (the web.xml file)

I hope this helps you


It is a mistake to think you can solve any major problems just with potatoes.<br />--Douglas Adams
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Typically, you would put it in "WEB-INF/tld/" (although I think any place under WEB-INF is acceptable)


No, that is not a good idea.

It is not necessary to copy the tld file out of the jar file and place it anywhere. Doing so just makes one more thing that can get out of date or go wrong.

No tld files, and no goop in the web.xml are neccessary. Simply dropping the appropriate jar files in WEB-INF/lib and putting the taglib directive in the JSP is all that is needed. Anything else just gets in the way.
[ April 14, 2006: Message edited by: Bear Bibeault ]
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
Hey guys, after I put jstl.jar and standard.jar files in Tomcat5.5/webapp/../WIN-INF/lib, it works now. I guess the it takes time for the server to reconfigure. Thank you for your great help.
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
No tld files, and no goop in the web.xml are neccessary. Simply dropping the appropriate jar files in WEB-INF/lib and putting the taglib directive in the JSP is all that is needed.


So what do you use for the URI in the taglib directive? The path and name to the actual TLD file?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Originally posted by Tony Smith:


So what do you use for the URI in the taglib directive? The path and name to the actual TLD file?


No, the URI that is defined within the TLD file itself.
[ May 10, 2006: Message edited by: Bear Bibeault ]
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
Sorry to be a n00b, but I like degoopification.

Can you provide an example of a uri-less taglib directive?


<%@ taglib prefix="c"%>

...doesn't seem to be sufficient.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Who said anything about URI-less directives?

The TLD defines a URI for itself, and the directive references it.

For example, here's a fragment from a TLD from one of my projects (with the project name replaced by "xyz"):



If this TLD file is placed in the WEB-INF hierarchy, (or within the META-INF folder of a jar file in the classpath), the taglib directive would be



No web.xml nonsense necessary.

Note that libraries like the JSTL, which have their TLD files ensconced within the jar file's META-INF folder, do not need for those TLD files to be extracted from the jar and placed somewhere else.

Also notice that at no time does the physical location of the TLD file play a part (except that it must be somewhere where the container will look for it as mentioned above). The matchup is made solely via the URI.
[ May 10, 2006: Message edited by: Bear Bibeault ]
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
That's great information, thanks for posting it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL problem