Alex,
I'm guessing that the removal of the login bean from the session scope is
only something done for a login action in order to remove the users password
from the session. I can sorta see the sense in that. I copied/pasted the
login page myself when I started my first struts app and was wondering why I
was removing my beans. Since then I've removed those lines from my pages and
am using the struts.config to manage my formbeans scopes etc.


-----Original Message-----
From: Alex Colic [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 09, 2001 8:52 AM
To: Struts
Subject: Please explain these lines to me.


Hi,

I amusing the example struts app to modify my present web app. I am using
one bean across a number of forms. Each form populates this bean.

In my loginaction servlet I create an instance of a bean and place it into
the session.

I then intend to have that bean used across all forms. In the second page I
have the following lines in my Page2action servlet:

if(mapping.getAttribute()!=null)
    {
      if("request".equals(mapping.getScope()))
        {
          request.removeAttribute(mapping.getAttribute());
        }
      else
        {
          session.removeAttribute(mapping.getAttribute());
        }
    }
    return (mapping.findForward("success"));


Why are these lines there. I can understand that if the present bean being
used is of request scope then take it out but then why are you also taking
out a bean that is of session scope? When my app gets to page 3 the info
entered on page one is gone. What I think is happening is that page 2 fills
the bean, the page 2 action servlet removes the bean from the session. When
page 3 gets the bean, it does not exist so it is created but it is empty.

Should the remove bean from session lines be removed?

Thanks

Alex

Reply via email to