You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Darren Hall <dh...@utrs.com> on 2006/09/21 15:52:56 UTC

Losing session object?

Quick question -

I have a web application built on Struts 1.2.9. The home page places a
"user" object in the current session when it executes using the following
code:

.

//Call common methods

userSession = getUserSession(request);

request.getSession().setAttribute("userSession", userSession);

.

One of the tiles in my jsp layout reads out values from my userSession bean
using the following code:

.

<bean:write name="userSession" property="domain(Primary)"/>

.

This works fine, and the home page displays correctly. Some links from the
home page use action forwards directly to jsp pages with no Action classes
associated with them. In these cases, I again try to read values from the
userSesison bean (as above) and I get a "javax.servlet.jsp.JspException:
Cannot find bean: "userSession" in any scope" error when these jsp pages are
loading. Why is this happening? If I've already put the "user" object in the
session when the user first hits the home page, shouldn't that object
persist to other jsp pages??

 

Thanks,

Darren


Re: Losing session object?

Posted by Chris Pratt <th...@gmail.com>.
By doing a forward (as opposed to a redirect) you actually have access to
more data, not less.  You have access to the request, session and
application scopes with a forward, whereas you only have session and
application scope access with a redirect.  Notice though that you should
always have access to the session from within the same web application
context.  So the two possibilities that come to mind are that you are moving
from one web application context to another (i.e. from one war file to
another) or that you have  <%@ page session="false"%> at the top of your
pages, explicitly blocking session access.
  (*Chris*)

On 9/21/06, Darren Hall <dh...@utrs.com> wrote:
>
> I'm thinking my problem might be related to the fact that my mappings in
> struts-config.xml are using forwards? Does this sound like it could be the
> problem? For example, from the home page you can link to the FAQ page.
> Here
> is the mapping for the FAQ page from my struts-congif.xml file: "<action
> path="/home/faqs/" forward="flc.faqs" />". By doing a forward action, does
> my session get losdt somehow?
>
> -D
>
> >
> > Quick question -
> >
> > I have a web application built on Struts 1.2.9. The home page places a
> > "user" object in the current session when it executes using the
> following
> > code:
> > ...
> > //Call common methods
> > userSession = getUserSession(request);
> > request.getSession().setAttribute("userSession", userSession);
> > ...
> > One of the tiles in my jsp layout reads out values from my userSession
> > bean using the following code:
> > ...
> > <bean:write name="userSession" property="domain(Primary)"/>
> > ...
> > This works fine, and the home page displays correctly. Some links from
> the
> > home page use action forwards directly to jsp pages with no Action
> classes
> > associated with them. In these cases, I again try to read values from
> the
> > userSesison bean (as above) and I get a "javax.servlet.jsp.JspException:
> > Cannot find bean: "userSession" in any scope" error when these jsp pages
> > are loading. Why is this happening? If I've already put the "user"
> object
> > in the session when the user first hits the home page, shouldn't that
> > object persist to other jsp pages??
> >
> > Thanks,
> > Darren
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: Losing session object?

Posted by Darren Hall <dh...@utrs.com>.
I'm thinking my problem might be related to the fact that my mappings in
struts-config.xml are using forwards? Does this sound like it could be the
problem? For example, from the home page you can link to the FAQ page. Here
is the mapping for the FAQ page from my struts-congif.xml file: "<action
path="/home/faqs/" forward="flc.faqs" />". By doing a forward action, does
my session get losdt somehow?

-D

>
> Quick question -
> 
> I have a web application built on Struts 1.2.9. The home page places a
> "user" object in the current session when it executes using the following
> code:
> ...
> //Call common methods
> userSession = getUserSession(request);
> request.getSession().setAttribute("userSession", userSession);
> ...
> One of the tiles in my jsp layout reads out values from my userSession 
> bean using the following code:
> ...
> <bean:write name="userSession" property="domain(Primary)"/>
> ...
> This works fine, and the home page displays correctly. Some links from the
> home page use action forwards directly to jsp pages with no Action classes
> associated with them. In these cases, I again try to read values from the
> userSesison bean (as above) and I get a "javax.servlet.jsp.JspException:
> Cannot find bean: "userSession" in any scope" error when these jsp pages 
> are loading. Why is this happening? If I've already put the "user" object 
> in the session when the user first hits the home page, shouldn't that 
> object persist to other jsp pages??
> 
> Thanks,
> Darren
>


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