16

I'm playing with Google App Engine in IntelliJ. I'm trying to use JSTL tags in my JSPs. I've tried two different URIs I found on the internet, and both of them give me errors:

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

and

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

It reds out the URL and says it cannot resolve taglib. I've tried dropping different parts of the URL to see if Ctrl-Space gives me any autocomplete love, but no luck.

Any ideas what I need to do to make this work?

Joel
  • 16,474
  • 17
  • 72
  • 93
  • 1
    What IDEA version do you use? IDEA 10.5.1 should handle it fine, but there was a problem with IDEA 10.0.3. We also have similar bug report for 10.5, but we are not able to reproduce it: http://youtrack.jetbrains.net/issue/IDEA-69942. Try to reinstall IDEA 10.5.1 or 10.5.2 from http://confluence.jetbrains.net/display/IDEADEV/IDEA+10.5+EAP. – CrazyCoder Aug 31 '11 at 08:13
  • I'm on 10.5.1 (June 29, 2011). Could it be because I don't have the J2EE sdk installed on my machine? It never occurred to me as the problem since IntelliJ usually auto-downloads any jars for built-in support. – Joel Aug 31 '11 at 15:05
  • You need JSTL libraries downloaded and added to the module dependencies: http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html. – CrazyCoder Aug 31 '11 at 15:58
  • 1
    yeah, I feel silly now. If you want to add that as an answer I'll mark it as correct. Thanks for the help. – Joel Sep 01 '11 at 05:36
  • http://stackoverflow.com/questions/31043869/intellij-and-jsp-jstl-cannot-resolve-taglib-for-jstl-in-tomcat7/32444393#32444393 – Shams Ul Azeem Sep 08 '15 at 13:24

5 Answers5

27

Make sure that JSTL library jars are added to the module dependencies.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
14

Add something like this to your pom.xml under the <dependencies> node (you are using maven, right?):

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

For gradle and other build systems see https://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5

Also, make sure you pick a suitable version for your project. To see all available versions check here.

ccpizza
  • 28,968
  • 18
  • 162
  • 169
0

In my case, I had to download the .jar from apache (https://tomcat.apache.org/taglibs/standard/) and add to my project dependencies.

File > Project Structure > Modules > Dependencies
Vítor Oliveira
  • 1,851
  • 18
  • 23
0

I resolved it by adding jstl-1.2 in the libraries.

  • Right-click on "project"
  • Then go into "open modules setting"
  • Then in "libraries" click on the "+", then "add with maven"
  • Click on the checkbox to download in a folder, change the folder path for .../WEB-INF/lib (create the lib folder)

    enter image description here

kaya3
  • 47,440
  • 4
  • 68
  • 97
MykoCh
  • 11
  • 2
  • 5
0

For using JSTL tags in IntelliJ IDEA Community and Ultimate editions, we need to add jstl and jstl-api dependencies.

If you are using Tomcat 10.1.12:

<dependency>
    <groupId>jakarta.servlet.jsp.jstl</groupId>
    <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
    <version>2.0.0</version>
</dependency>

If your are using Tomcat 9:

<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>javax.servlet.jsp.jstl-api</artifactId>
    <version>1.2.6</version>
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.6</version>
</dependency>

And don't forget to add taglib directive on top of the jsp page before restarting the IDE:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
ahuemmer
  • 1,653
  • 9
  • 22
  • 29