3

I have read through nearly every answer to this question on SO and have tried over a dozen different "solutions" but I cannot get JSTL to work in a Spring boot web app using servlet 3.1 within Tomcat 8.0. I continue to receive this 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.

I use Maven to build the project but have also manually copied JARs as well in hopes that would help but alas, it has not! I hope I am just overlooking something stupid. Can someone please tell me what I am doing wrong??

Things I have tried (for all of these, this is the included line in a simple index.jsp file -

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  1. Added the following dependency to my pom.xml (XML chars removed to format better)

    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    

    This puts the jstl-1.2.jar in my WEB-INF/lib directory and I have confirmed it is there when I deploy to Tomcat - this doesn't work

  2. Removed the above dependency and added these dependencies per the suggestion here (http://www.murraywilliams.com/2011/11/running-jstl-1-2-on-tomcat-7-using-maven/)

    <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>
       </exclusions>
    </dependency>
    

    This puts two additional JAR files in my WEB-INF/lib directory, a jstl-api-1.2.jar and jstl-impl-1.2.jar, and I have confirmed they are there when I deploy to Tomcat - this doesn't work

  3. I have also tried changing the scope to 'provided' for each of those dependencies while placing the respective JARs in Tomcat's lib directory and restarted Tomcat and still doesn't work.

Here is my web.xml header

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

Anyways, any help is greatly appreciated!

lkamal
  • 3,788
  • 1
  • 20
  • 34
Matt Crysler
  • 865
  • 3
  • 11
  • 23
  • Are you implying that it works fine when you don't use Spring Boot? – BalusC Sep 13 '15 at 10:56
  • No, but I know that Spring Boot does so much stuff behind the scenes that I felt like mentioning its use might be relevant. Though I did run a dependency tree on my project and saw no other JARs pulling in conflicting JSTL JARs. – Matt Crysler Sep 13 '15 at 14:50
  • I don't want to post an answer to this question since it doesn't really answer the actual question but I have decided to use Thymeleaf to handle the views instead of JSP. There is only a small learning curve and it integrates with Spring 4 (and Spring Boot) really well. I would encourage others to make the switch as well! – Matt Crysler Sep 17 '15 at 04:25

3 Answers3

0

Try checking Tomcat's catalina.properties file. Find the setting called tomcat.util.scan.StandardJarScanFilter.jarsToScan. Add the names of your taglib jars. In my case I added taglibs*.jar as my jars were called taglibs-standard-impl-1.2.5.jar and taglibs-standard-spec-1.2.5.jar.

If catalina.properties has a lot of jars in the jarsToSkip setting, the taglibs might not be found, so adding them to the jarsToScan can fix it. Tomcat experts, please correct if I'm understanding incorrectly. However, this has solved it for me.

jabe
  • 784
  • 2
  • 15
  • 33
-1

You shouldn't use scope as provided since tomcat doesn't jstl library

Haibo Yan
  • 11
  • 2
-1

I think you just need to change the group id from javax.servlet.jsp.jstl to javax.servlet as shown below.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
lkamal
  • 3,788
  • 1
  • 20
  • 34
  • 1
    Could someone please give a comment why this reply is given negative point? Given issue got solved with this approach, hence I believe a valid reason should be provided with the negative mark. – lkamal Aug 03 '17 at 17:19