You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Shkuro, Yuri" <Yu...@gs.com> on 2001/02/20 18:55:37 UTC

Session atribute lost on forward

Sorry for a question not directly related to struts.

My app is always enterred through login.do action, which authenticates
the user and sets a login bean in session attribute and returns some
forward based on user access level.  However, when the forward page is
displayed (along with the list of session attributes), the login bean
is not there if the session has isNew()==true.  If you hit reload, the
session.isNew()==false and the attribute appears.  It seems that when
I store something in a new session and then do an internal forward,
the request in the second page doesn't have info about the session, and
all attributes are lost.  Any idea how to fix this?

This is on Tomcat 3.2.1.  Here is the action class's perform() method.

    public ActionForward perform(ActionMapping mapping,
								ActionForm
form,
	
HttpServletRequest request,
	
HttpServletResponse response)
	  throws IOException, ServletException
	{
		String sKerberosID = request.getRemoteUser();

		// create login bean for this user & this application
		LoginBean login = new LoginBean( sKerberosID );

		// store login bean as a session-scope bean
		request.getSession().setAttribute( LoginBean.getKey(), login
);

		return mapping.findForward( login.getSuperuser() ?
"superuser" : "success" );
    }

RE: Session atribute lost on forward

Posted by Sibon Barman <si...@ss8.com>.
Hi,
Did you ever figure out the solution for the problem ---- I have the exact
same problem.

Sibon Barman
SS8 Networks, Inc.
Suite 500
495 March Road, Kanata,
Ontario K2K 3G1

*: (613)592-2100 ext:3281
*: sibon@ss8.com



-----Original Message-----
From: Shkuro, Yuri [mailto:Yuri.Shkuro@gs.com]
Sent: Tuesday, February 20, 2001 12:56 PM
To: 'struts-user@jakarta.apache.org'
Subject: Session atribute lost on forward


Sorry for a question not directly related to struts.

My app is always enterred through login.do action, which authenticates
the user and sets a login bean in session attribute and returns some
forward based on user access level.  However, when the forward page is
displayed (along with the list of session attributes), the login bean
is not there if the session has isNew()==true.  If you hit reload, the
session.isNew()==false and the attribute appears.  It seems that when
I store something in a new session and then do an internal forward,
the request in the second page doesn't have info about the session, and
all attributes are lost.  Any idea how to fix this?

This is on Tomcat 3.2.1.  Here is the action class's perform() method.

    public ActionForward perform(ActionMapping mapping,
								ActionForm
form,

HttpServletRequest request,

HttpServletResponse response)
	  throws IOException, ServletException
	{
		String sKerberosID = request.getRemoteUser();

		// create login bean for this user & this application
		LoginBean login = new LoginBean( sKerberosID );

		// store login bean as a session-scope bean
		request.getSession().setAttribute( LoginBean.getKey(), login
);

		return mapping.findForward( login.getSuperuser() ?
"superuser" : "success" );
    }