You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2003/10/17 08:12:59 UTC
Where Do I Create Session, Set Attributes in Struts?
I use container-managed form-based authentication to
verify users (it works well).
Now, I want to create a session and set user's name
after users successfully log in:
HttpSession session = request.getSession( true );
if ( session.isNew() )
{
student.setName(request.getParameter("username"));
session.setAttribute("student", student);
Student stud =
(Student)session.getAttribute("student");
}
First of all, in the context of container managed
authentication, can I write:
student.setName(request.getParameter("username"));
Second, what is the proper place to insert the
aforementioned codes.
The container intercepts and takes care of the
authentication when
<forward
name="logon"
redirect="true"
path="/do/Menu"/>
and the action controller is in the scaffold folder:
<action
path="/Menu"
name="menuForm"
type="org.apache.struts.scaffold.ExistsAttributeAction"
parameter="application;HOURS">
<forward
name="success"
path=".article.Menu"/>
<forward
name="failure"
path="/do/MenuCreate"/>
</action>
where .article.Menu is a tile.
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org