Monday, February 15, 2010

Solving "JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved"

I believe that any Java EE Web developer working with Spring, Tomcat, JSP, and JSTL has gone through this error at least once:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
 org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
 org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
 org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
 org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
 org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
 org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:429)
 org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
 org.apache.jasper.compiler.Parser.parseElements(Parser.java:1439)
 org.apache.jasper.compiler.Parser.parse(Parser.java:137)
 org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
 org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
 org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
This means that Tomcat cannot find the JSTL library.

If you use Maven, simply add this dependency to your pom.xml (inside <dependencies>):
        <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
        </dependency

Make sure that you use the correct taglib meta-tag :
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

No comments:

Post a Comment