IntelliJ and JSP/JSTL cannot resolve taglib for JSTL in tomcat7

First of all my JSTl code works on my server because i have the proper Jar file in the Lib folder in tomcat7. This is just really an IDEA problem. My questions comes down to where i put the same jar file in my file directory within IntelliJ.

I have ran into a error in IntelliJ and JSTL.

My problem is that when i use

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

It results in Cannot resolve taglib with uri. I have tried different Jar files and I do know that i have to correct version for my servlet.

Im running tomcat7 on Ubuntu Server 15.04, and IntelliJ 14.1.3.

I have tried importing the jar file though the Project Structure, and including it in various places but still the same error after re-building the project, and closing down and reopening the IDEA.

This sample code runs when deployed to tomcat but IntelliJ keeps giving errors.

<table border="1">
    <c:forEach var="a" items="${data}">
        <tr>
            <td>${a}</td>
        </tr>
    </c:forEach>
</table>

<c:forEach begin="0" end="255" var="i">
    <span style='color:rgb(
        <c:out value="${i}"/>,
        <c:out value="${i}"/>,
        <c:out value="${i}"/>);'>
        <c:out value="${i}"/></span> <br />
</c:forEach>

I would like to know how to stop IntelliJ from giving errors on my Syntax even though the code works.

I have read JSTL in IntelliJ gives errors in JSP

and

https://www.jetbrains.com/idea/features/jsp_editor.html

Still no luck.


First add this to the top of your .jsp file:

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

It will still give syntax error but you can fix that by adding javax.servlet:jstl:1.2 as a module dependency. To do that, follow these steps:

  1. Click your project name and press F4 to bring up the module settings dialog.
  2. Then go to the dependencies tab in the modules section.
  3. Click the green + icon library From Maven.
  4. Search for javax.servlet:jstl:1.2 in the search bar and press OK and it will download and add the above mentioned library as a module.
  5. Now you should not have any kind of syntax error.

If you are using maven, add following code in pom.xml inside the <dependencies></dependencies> tag

<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>