Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding JSTL to jsp (Tomcat 8) [duplicate]

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?

like image 620
user1007522 Avatar asked Jan 19 '15 14:01

user1007522


People also ask

Does Tomcat include JSTL?

Tomcat does not provide the Java Server Tag Library (JSTL), which is required to use JSP pages as Spring views. The IdP status page at /idp/status is built with JSP and will not work without this library. You can download it from here, place it into idp. home/edit-webapp/WEB-INF/lib/ , then change to idp.

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.


1 Answers

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.

like image 52
z21 Avatar answered Oct 04 '22 20:10

z21