aspose file tools*
The moose likes Struts and the fly likes session in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "session in struts" Watch "session in struts" New topic
Author

session in struts

zaheer agadi
Ranch Hand

Joined: Jan 02, 2006
Posts: 32
how is session implememted and maintained in struts?


CHEERS<br />Zaheer SCJP(1.4)
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
HI Zaheer,
You may maintain sessions by putting it in the Action class(Controller).You may check all the action classes for the loginForm(which contains the username and password) and accordingly allow access or invalidate a users session.
---------
Example:
---------
public final class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception
{
LoginForm loginForm=(LoginForm)form;
//Call Business Logic Class
// Some Logic

// Set the session bean
HttpSession session = request.getSession();
session.setAttribute("loginForm", loginForm);
}

return(mapping.findForward("login"));
}

Hope that is alright.. I believe posting specific questions would help better rather than such generic questions.
Reagrds,
Roshani


Regards,<br />Roshani
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Struts is really a pretty thin layer over top of the basic servlet architecture. The short answer is that sessions are maintained in struts just like they are in a servlet based application. So you have specific questions?

- Brent
zaheer agadi
Ranch Hand

Joined: Jan 02, 2006
Posts: 32
Thnx Roshni and Brent calrifyin my doubt i just wanted to know is der any different way in struts to handle session, thnx
 
wood burning stoves
 
subject: session in struts