5

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
rosu alin
  • 5,674
  • 11
  • 69
  • 150

3 Answers3

11

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • still the same error with the taglib changed, I'm gonna check the wiki page for some info, maybe i'll sort it out somehow, thanks :D – rosu alin Apr 03 '12 at 06:03
  • Thank you for the link to the jstl-1.2.jar file. I have now tried with several files saying they were 1.2, but they didn't work. THANK YOU – Mads Nov 14 '12 at 15:14
1

I think you should include jstl-1.2.jar.

QuickSilver
  • 3,915
  • 2
  • 13
  • 29
Ramesh PVK
  • 15,200
  • 2
  • 46
  • 50
1

Also, instead of

<c:if test="${session.getAttribute('logged')!=null}">  

use one of the following

<c:if test="${sessionScoped.logged != null}">  
<c:if test="${sessionScoped[logged] != null}">
<c:if test="${logged != null}">
rickz
  • 4,324
  • 2
  • 19
  • 30