Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 594
Joel Avatar asked Aug 31 '11 05:08

Joel


People also ask

Can I use JSP in Intellij?

Hi all, I am new to java and intellij, so i downloaded the student version and lunch java web page application the index. jsp worked fine after adding some html elements to it.

What is the difference between JSP and JSTL?

JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).

What is the use of JSTL tags in JSP?

JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.

How to handle error object in JSP using JSTL tags?

How to handle error object in JSP using JSTL tags? You can make use of JSTL tags to write an error page ShowError.jsp with better structure and more information − Opps... java.lang.RuntimeException: Error condition!!!

How to fix JSTL jar is not working in Java?

Adding the old javax.servlet:jstl dependency solves the issue. The problem is there because by default jstl jar is added for scope Compile Time Only We need to make it to get added for Runtime to do that. Click your project name and press F4 to bring up the module settings dialog or Right Click on Project name and find Open Module Settings.

How to add JSTL jar to runtime in Eclipse?

The problem is there because by default jstl jar is added for scope Compile Time Only We need to make it to get added for Runtime to do that. Click your project name and press F4 to bring up the module settings dialog or Right Click on Project name and find Open Module Settings. Go to the dependencies tab in the modules section.

How to add JSTL library as a module in Java?

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. Now you should not have any kind of syntax error. In my case adding the dependency javax.servlet:jstl:1.2 didn't work. Adding the dependency jstl:jstl:1.2 worked.


2 Answers

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

like image 171
CrazyCoder Avatar answered Sep 20 '22 19:09

CrazyCoder


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.

like image 25
ccpizza Avatar answered Sep 21 '22 19:09

ccpizza