• 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 problem

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
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
Where did you put the jstl.jar and standard.jar files?
 
Phoebe Song
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
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
It's all in the JSP FAQ.
 
Phoebe Song
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
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
Which version of the JSTL did you download?
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Sheriff
Posts: 67746
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

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

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
Sheriff
Posts: 67746
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

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
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
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
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
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's great information, thanks for posting it!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic