The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

rosu alin picture rosu alin · Apr 2, 2012 · Viewed 40.5k times · Source

i need some help, i wanted to do a program and used

if(session.getAttribute("logged")!="1"){ 
 String err="You must be logged in!!"; 
 request.setAttribute( "error", err ); 
 String nextJSP = "/login.jsp"; 
 RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); 
dispatcher.forward(request,response); }

%>

In a jsp, but my boss told me to use jstl So i changed it to:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
 <c:if test="${session.getAttribute('logged')!=null}"> 
      <jsp:forward page="login.jsp">
      </jsp:forward>
 </c:if>
 <c:if test="${session.getAttribute('logged')==null}">
      <jsp:forward page="princ.jsp"> </jsp:forward>
 </c:if>

And i get a nasty error:

 "org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application " 

I searched the internet for some fixes, i've put the javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar in my library, even put javaee.jar in the Tomcat library, but still got no solution to this, can somebody help me please? PS: i got Eclipse Java EE IDE for Web Developers.(INDIGO) Tomcat 7.08

Answer

BalusC picture BalusC · Apr 2, 2012

Your taglib URI is wrong.

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

This URI is from the old and EOL'ed JSTL 1.0 library. Since JSTL 1.1, you need an extra /jsp in the path because the taglib's internal workings were changed because the EL part was moved from JSTL to JSP:

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

Further, the JAR files which you attempted to drop in /WEB-INF/lib are wrong. The javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar is contains only the JSTL javadocs and the javaee.jar contains the entire Java EE API which may be desastreus because Tomcat ships with parts of it already (JSP/Servlet) which may conflict.

Remove them all. You need the jstl-1.2.jar file.

See also: