You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Lipscombe <ad...@expensys.com> on 2004/06/23 16:12:25 UTC

RE: logic:redirect not working (problem with dynamic jsp:include?)

Folks,


I have discovered that if I use the <jsp:include> mechanism then the code
below does not work.
It does work if I use the <%@ include file="..." %> construct.

So, there appears to be a problem with using logic:redirect in a dynamically
included JSP? 

Any ideas?


TIA - Adam


-----Original Message-----
From: Adam Lipscombe [mailto:adam.lipscombe@expensys.com] 
Sent: 23 June 2004 13:48
To: 'Struts Users Mailing List'; 'Struts Users Mailing List'
Subject: logic:redirect not working


Folks,


I am trying to implement a simple login gate to ensure a user is logged in.



My code is below. 
When a user is logged in successfully a session attribute named
"userContext" is present, and this has a property named "user". There is a
global forward called "login"


LoginGate.jsp:

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ page
import="com.expensys.expensyswt.resources.Constants" %> <%@ page
import="java.util.logging.Logger" %>

<%logger.info("userContext = " +
session.getAttribute(Constants.USER_CONTEXT));%>

<!-- Redirect user to login page if no UserContext found -->
<logic:notPresent name="userContext" property="user" scope="session" >
  <%logger.info("not present");%>
  <logic:redirect forward="login" />
</logic:notPresent>


Home.jsp

[snip..]
<jsp:include flush="false" page="common/LoginGate.jsp" />

<html:html>
[snip..]



I am puzzled. The redirect does not work.
The log statements indicate that the code block is being called - i.e. "not
present" is output.


Any ideas what is wrong?



TIA - Adam


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: logic:redirect not working (problem with dynamic jsp:include?)

Posted by Kris Schneider <kr...@dotech.com>.
Any attempts by an included resource to change headers or response status codes
should be ignored, that's just part of the spec. An include *directive* might
work, but this sort of functionality really doesn't belong in a JSP. If you're
using at least a Servlet 2.3 container, try a Filter. Otherwise, try a custom
Struts RequestProcessor.

Quoting Adam Lipscombe <ad...@expensys.com>:

> Folks,
> 
> 
> I have discovered that if I use the <jsp:include> mechanism then the code
> below does not work.
> It does work if I use the <%@ include file="..." %> construct.
> 
> So, there appears to be a problem with using logic:redirect in a dynamically
> included JSP? 
> 
> Any ideas?
> 
> 
> TIA - Adam
> 
> 
> -----Original Message-----
> From: Adam Lipscombe [mailto:adam.lipscombe@expensys.com] 
> Sent: 23 June 2004 13:48
> To: 'Struts Users Mailing List'; 'Struts Users Mailing List'
> Subject: logic:redirect not working
> 
> 
> Folks,
> 
> 
> I am trying to implement a simple login gate to ensure a user is logged in.
> 
> 
> 
> My code is below. 
> When a user is logged in successfully a session attribute named
> "userContext" is present, and this has a property named "user". There is a
> global forward called "login"
> 
> 
> LoginGate.jsp:
> 
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ page
> import="com.expensys.expensyswt.resources.Constants" %> <%@ page
> import="java.util.logging.Logger" %>
> 
> <%logger.info("userContext = " +
> session.getAttribute(Constants.USER_CONTEXT));%>
> 
> <!-- Redirect user to login page if no UserContext found -->
> <logic:notPresent name="userContext" property="user" scope="session" >
>   <%logger.info("not present");%>
>   <logic:redirect forward="login" />
> </logic:notPresent>
> 
> 
> Home.jsp
> 
> [snip..]
> <jsp:include flush="false" page="common/LoginGate.jsp" />
> 
> <html:html>
> [snip..]
> 
> 
> 
> I am puzzled. The redirect does not work.
> The log statements indicate that the code block is being called - i.e. "not
> present" is output.
> 
> 
> Any ideas what is wrong?
> 
> 
> 
> TIA - Adam

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org