struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Is "request" shared across a redirect?
Date Thu, 01 Feb 2001 00:06:24 GMT
James Howe wrote:

> I have two JSP pages which I want to have share a bean.  In the first JSP
> page I do something like this:
> [...]
> <jsp:useBean id="bean" scope="request" class="package.BeanClass"/>
> <jsp:setProperty name="bean" property="prop" value='Some Value'/>
> <logic:redirect href="foo.jsp"/>
> [...]
> In "foo.jsp", I have code which looks like this:
> [...]
> <logic:notPresent name="bean" scope="request">
>         <h3>Message not available</h3>
> </logic:notPresent>
> <logic:present name="bean" scope="request">
>         <jsp:useBean id="bean" scope="request" class="package.BeanClass"/>
>         <h3><bean:write name="bean" property="prop" filter="true"/></h3>
> </logic:present>
> [...]
> When I invoke the first page, I make the transition to the second page, but
> the bean property is never found.  I've debugged the code and it appears
> that the request object used by the second page does not have the attribute
> defined by the first page.  I guess I thought that objects put into the
> request scope were maintained across a redirection.  Was I wrong or am I
> just doing something stupid?

Request scope objects are retained across a *forward* but not across a
*redirect*.  The reason is that a redirect is actually a message sent back to
the browser, which then submits a second request to the new URL.  The request
attributes are not shared because it is not the same request any longer.

Session scope objects, on the other hand, would be retained across the

> Thanks.


View raw message