Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Expression Language question

Nikola Milutinovic

2003-06-01

Replies:

Simple question.

I have a JSP/Servlet combination in which Servlet is used to authenticate user and create a session. A JSP page then checks for the existence of the session and reads neccessary ID from it. I'm switching to JSTL and I'd like to switch to EL, now. Here is the old code, how can I translate it to EL?

OLD CODE
-------------
<%@(protected)"
     ...
     session="true"
     ...
%>
<%@(protected)" %>
<%@(protected)" %>
<%
if (session.isNew()) {
response.sendRedirect( response.encodeRedirectURL( "Error.jsp?reason=Wrong+login" ) );
}
%>

NEW CODE (the only thing I can come up with)
-------------------------------------------------
<%@(protected)"
     ...
     session="true"
     ...
%>
<%@(protected)" %>
<%@(protected)" %>
<c:if test="${empty sessionScope.userID}"/>
<c:redirect url="Error.jsp?reason=Not+logged+in"/>
</c:if>
---------------------------------------------
Anybody got a better idea?

Nix.
©2008 junlu.com - Jax Systems, LLC, U.S.A.