Lance Lavandowska wrote:
> it isn't clear if checkLoggedIn() does the redirect itself (as it looks),
> but place a return; after the response.sendRedirect().
>
> To change your code for purposes of example:
>
> <%
> if ( !myObject.checkLoggedIn(response) ) // returns false if user not
> logged in
> {
> response.sendRedirect(notLoggedInURL);
> return;
> }
> %>
>
You can do the same thing without an extra round trip to the client, if you want,
by using <jsp:forward>. Assume that the same change Lance described above is in
place, so that checkLoggedIn() returns true or false. If you do this, the
checkLoggedIn method also doesn't need access to the response object.
<% if (!myObject.checkLoggedIn()) { %>
<jsp:forward page="/loginPage.jsp" />
<% } %>
Note that no return statement is necessary here -- <jsp:forward> automatically
terminates processing of the remainder of this page. The current spec language on
this is not real clear, but you can expect it to be clarified.
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html