Joel
Joel

Reputation: 16664

JSTL in IntelliJ gives errors in JSP

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?

Upvotes: 16

Views: 24713

Answers (5)

monukd01dev
monukd01dev

Reputation: 29

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" %>

Upvotes: 0

MykoCh
MykoCh

Reputation: 11

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

Upvotes: 0

CrazyCoder
CrazyCoder

Reputation: 402581

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

Upvotes: 27

ccpizza
ccpizza

Reputation: 31831

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.

Upvotes: 14

V&#237;tor Oliveira
V&#237;tor Oliveira

Reputation: 2091

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

Upvotes: 0

Related Questions