Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSTL taglib URI is obsolete?

Tags:

java

jstl

I've been checking out Spring MVC tutorial and copied this small JSP code from there:

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

<html>
    <head><title>Training, Inc.</title></head>
    <body>
        <h2><c:out value="${message}" /></h2>
    </body>
</html>

There is a string set for message and the c:out tag just prints literally

${message}

I was hitting my head for a while until I remembered an issue I had before and changed the taglib URI to:

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

This solved my little problem

Some time ago I had a similar issue with XSLT transforming but in that case I had to change from http://java.sun.com/jstl/xml to http://java.sun.com/jsp/jstl/xml

According with this link my spring example should've worked just as I pasted from spring tutorial

The question is: Any of you guys know where is all this taglib URI confusion documented? Why in the some cases I got the last version from http://java.sun.com/jsp/jstl and in other ones I got the last version from http://java.sun.com/jstl

like image 856
victor hugo Avatar asked May 10 '09 18:05

victor hugo


People also ask

What is uri in Taglib?

The <uri> element in the TLD is a unique name for the tag library. That's it. It does NOT need to represent any actual location (path or URL, for example). It simply has to be a name—the same name you use in the taglib directive.

What is Taglib uri in JSP?

The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides means for identifying the custom tags in your JSP page. The taglib directive follows the syntax given below − <%@ taglib uri = "uri" prefix = "prefixOfTag" >

Which Taglib attribute is used for JSTL in JSP?

Install JSTL Library To use any of the libraries, you must include a <taglib> directive at the top of each JSP that uses the library.

What is the difference between JSTL and JSP?

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.).


2 Answers

Yes, it's well known that the URI for taglibs changed between JSTL versions 1.0 and 1.1. If you happen to get examples that use the old standard and try to use them with the new taglib JAR you'll have this problem.

like image 104
duffymo Avatar answered Oct 08 '22 12:10

duffymo


If you're still getting this error, but you're hand crafting your pom, you probably have missed the standard library. e.g. I'd missed

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>${jstl.version}</version>
    </dependency>
like image 21
Egwor Avatar answered Oct 08 '22 13:10

Egwor