Reputation: 523
I made a Spring MVC webapp in which I used JSTL tags. I launched it by Gradle and it worked perfectly fine:
gradle jettyRunWar
However, when I used the same WAR file with my Tomcat, I got error:
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.
Using stackoverflow, I was able to fix. Problem was in my build.gradle file where I didn't specify the JSTL dependencies. I fixed that and I was able to run my webapp in Tomcat as well.
My question is why Jetty was able to run this app when Tomcat wasn't. How could I have avoided this issue?
Upvotes: 1
Views: 1076
Reputation: 26077
Using JSTL Taglibs
The JavaServer Pages Standlard Tag Library (JSTL
) is part of the Jetty distribution and is automatically put on the classpath
when you select your flavour of JSP
. It is also automatically on the classpath
for the jetty maven plugin, which uses the Apache JSP
engine as of jetty-9.2.
Embedding
If you are using jetty in an embedded
scenario, and you need to use JSTL
, then you must ensure that the JSTL jars are included on the container's classpath
- that is the classpath
that is the parent of the webapp's classpath
. This is a restriction that arises from the Java EE specification.
The jars that you will include will depend on the flavour of JSP that you are using.
Tomcat has never included JSTL
.
You should put the jstl
and standard jars in WEB-INF/lib
Upvotes: 1