J
Jeano
Here is my problem. Let's say I am designing some kind of online
store. If the user attempts to review their account per the
'myAccount.jsp' page and they have not logged in, they should be
redirected to the 'login.jsp' page instead. There are a few additional
considerations:
1. myAccount.jsp doesn't do any actual work. It immediately uses
<jsp:include to call myAccountInner.jsp where all the actual magic
happens. For my particular app, I cannot use a "<%@ include", I must
use a <jsp:include. There is code in myAccount.jsp below the the
invocation of myAccountInner.jsp that I DO NOT want to get executed in
the event of a pending redirect.
2. When the user is done redirecting, I want their location bar to
read http://www.whatever.com/login.jsp.
I've tried seemingly thousands of combinations. I've tried
response.sendRedirect(), <jsp:forward, forwarding to a servlet that
performs a redirect - nothing I do seems to work.
What I am trying to do in my app seems simple enough. Seems like
millions of people would have come across this problem. Anyone have a
solution for me? Examples online? I am going nuts and would
appreciate thoughts that anyone might have. Thanks.
-j
-- myAccount.jsp ------------------------------------------
<%@ page language="java" buffer="16kb" %>
<jsp:include page="myAccountInner.jsp" flush="false" />
<%
// code here that I do not want to get executed
// in the event of a pending redirect
%>
-----------------------------------------------------------
-- myAccountInner.jsp -------------------------------------
<%
// if the user is not logged in, then redirect them to the
// login page
if ( !userLoggedIn )
{
response.sendRedirect("/login.jsp");
}
%>
-----------------------------------------------------------
-- login.jsp ----------------------------------------------
Please log in
<FORM ACTION="whatever..."
..
..
..
-----------------------------------------------------------
store. If the user attempts to review their account per the
'myAccount.jsp' page and they have not logged in, they should be
redirected to the 'login.jsp' page instead. There are a few additional
considerations:
1. myAccount.jsp doesn't do any actual work. It immediately uses
<jsp:include to call myAccountInner.jsp where all the actual magic
happens. For my particular app, I cannot use a "<%@ include", I must
use a <jsp:include. There is code in myAccount.jsp below the the
invocation of myAccountInner.jsp that I DO NOT want to get executed in
the event of a pending redirect.
2. When the user is done redirecting, I want their location bar to
read http://www.whatever.com/login.jsp.
I've tried seemingly thousands of combinations. I've tried
response.sendRedirect(), <jsp:forward, forwarding to a servlet that
performs a redirect - nothing I do seems to work.
What I am trying to do in my app seems simple enough. Seems like
millions of people would have come across this problem. Anyone have a
solution for me? Examples online? I am going nuts and would
appreciate thoughts that anyone might have. Thanks.
-j
-- myAccount.jsp ------------------------------------------
<%@ page language="java" buffer="16kb" %>
<jsp:include page="myAccountInner.jsp" flush="false" />
<%
// code here that I do not want to get executed
// in the event of a pending redirect
%>
-----------------------------------------------------------
-- myAccountInner.jsp -------------------------------------
<%
// if the user is not logged in, then redirect them to the
// login page
if ( !userLoggedIn )
{
response.sendRedirect("/login.jsp");
}
%>
-----------------------------------------------------------
-- login.jsp ----------------------------------------------
Please log in
<FORM ACTION="whatever..."
..
..
..
-----------------------------------------------------------