Lauren
Lauren

Reputation: 157

How to use taglibs JSTL/core with JAR in WEB-INF folder

Currently I have taglibs set up and working correctly using the following tag at the top of my JSP pages:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

In Maven I have the dependencies:

<dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>

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

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency> 

I need my web app to work without Internet connection i.e. not calling the URI in the taglib so I thought I could download the jstl-1.2.jar and put it in /WEB-INF/lib folder. Then I could have my tag as the following:

<%@ taglib uri="/WEB-INF/lib/jstl-1.2" prefix="c" %>

However, this is not working. It says that the tag library descriptor cannot be found. So my question is, how do I use JSTL in taglibs using a JAR in the WEB-INF folder, instead of calling the java sun website in the URI??

Do I need to put anything in web.xml? Do I remove my Maven dependencies? Do I need to put something in META-INF?

Any help would be much appreciated! Thanks!

Upvotes: 4

Views: 5454

Answers (1)

developerwjk
developerwjk

Reputation: 8659

The URI in

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

is not really a reference to the internet. Even after putting the Jar file in WEB-INF/lib/ you will leave the uri as that address. The servlet container is always looking for the jar in WEB-INF/lib/ and never downloads it from http://java.sun.com/jsp/jstl/core. That URI is more like a unique name identifying the taglib.

Check for yourself by clicking the link to http://java.sun.com/jsp/jstl/core There is no jar file to download there. Its just an identifier.

Upvotes: 8

Related Questions