6

I want to use the JSTL library in my jsp's. Now I followed a tutorial and it told me to add this line to the jsp page:

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

It gives me the error cannot resolve taglib with uri and then the URL.

I'm running tomcat 8. My web.xml is like this:

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Does someone know how to fix this?

user1007522
  • 7,858
  • 17
  • 69
  • 113

2 Answers2

4

You need to add jar for the jstl library in your classpath. If you are using maven, then add this dependency.

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

Add this to your pom.xml.

z21
  • 129
  • 6
  • Thank you :-) this solved the problem. I used the wrong dependency http://search.maven.org/#artifactdetails%7Ctaglibs%7Cc%7C1.1.2%7Cjar – user1007522 Jan 19 '15 at 14:44
3

To resolve this issue, you would need to do the following:

  • The jstl.jar should be in your classpath. (Download jar / pom)
  • Make sure you have the following taglib directive at the top of your jsp:

    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
SMA
  • 36,381
  • 8
  • 49
  • 73
  • 1
    Can I add them via maven? Because I tried but then it still failed. I included this one http://search.maven.org/#artifactdetails%7Ctaglibs%7Cc%7C1.1.2%7Cjar – user1007522 Jan 19 '15 at 14:40
  • 2
    Yes see [this](http://mvnrepository.com/artifact/jstl/jstl/1.2) for maven dependency. – SMA Jan 19 '15 at 14:42