I wrote a web application with Eclipse Tomcat and it works on my local Tomcat 7, when I tried to publish it online on a Tomcat 7, I had the following error:
SEVERE: Servlet.service() for servlet [obliquid.servlet.Index] in context with path [/cp] threw exception [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]
Tomcat 7 has "Spec versions: Servlet 3.0, JSP 2.2, EL 2.2", so JSTL is not included?
When I tried to upload standard.jar and jstl.jar I had the following error:
org.apache.jasper.JasperException: /jsp/index.jsp (line: 3, column: 62) Unable to read TLD "META-INF/c.tld" from JAR file "jndi:/localhost/cp/WEB-INF/lib/standard.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
I did some googling, but I couldn't sort it out, some said it could be caused by conflicting versions of the jars. Maybe I should not include those jars and use a different JSTL url? Mine is for JSTL 1.1 I think, is there a new URL for JSTL 1.2?
What should I do to solve the problem and make this application run?
You can dive into our beloved stackoverflow.com to find out that Tomcat doesn't include JSTL,not even in Tomcat 8, in spite that they have an implementation of the JSP Standard Tag Library (JSTL) specification, versions 1.0, 1.1 and 1.2.
JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).
JavaServer Pages Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. Here we will be discussing how to use the Maven build tool to add JSTL support to a Spring MVC application.
I have been fighting with this for several hours. Here is a complete solution.
I am using Tomcat 7, which is a Servlet 3.0-compliant server.
If you desire to use the Servlet 3.0 spec, you must have your web.xml as follows:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
If you're using Maven, your pom.xml should have these lines.
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>jstl-impl</artifactId> <version>1.2</version> <exclusions> <exclusion> <artifactId>servlet-api</artifactId> <groupId>javax.servlet</groupId> </exclusion> <exclusion> <artifactId>jsp-api</artifactId> <groupId>javax.servlet.jsp</groupId> </exclusion> <exclusion> <artifactId>jstl-api</artifactId> <groupId>javax.servlet.jsp.jstl</groupId> </exclusion> </exclusions> </dependency>
These dependencies are very important. JSTL 2.1 + Tomcat 7 + Servlet 3.0 is very broken unless you fix it by using these lines, especially the exclusion part. What is happening is the JSTL 2.1 Jars are actually pulling in the wrong versions of the Servlet spec--2.5. Unless you stop that from happening, you will be in a whole world of pain. A special thanks to Mr. Murray Todd Williams for these insights .
Finally, in case Maven can't find those JARS, you can make Eclipse happy by including three JARS with your project and doing the usual Project--> Properties--> Java Build Path and include them that way--though Maven should take care of it.
javax.servlet-api-3.0.1.jar javax.servlet.jsp.jstl-1.2.1.jar javax.servlet.jsp.jstl-api-1.2.1.jar
Please note! This exact configuration only applies if you are using the magic combination of:
A Servlet 3.0-compliant application server such as Tomcat 7
Your web.xml has the right namespace for the Servlet 3.0 spec
You have those three JARS and no other JSTL or Servlet JARS on your classpath.
Make sure you do not place copies of these JARs in your WEB-INF/lib directory because they would in that case be sent to the server thereby causing LinkageErrors.
In your JSP, you need to have this PRECISE line, formatted exactly as I have it or else Eclipse will whine that it doesn't recognize the c:blah tags:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
What a danged PITA! This is MUCH harder to implement than any other version of JSTL. This is the only example of something getting much more complicated rather than simpler in later iterations.
Tomcat has never included JSTL.
You should put the jstl and standard jars in WEB-INF/lib
(you've done that), and make sure you have the permissions to read them (chmod)
Your URI is correct and it should work (works here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With