[S2] Newbie question about HTTP Sessions
Hi A couple of newbie questions. Firstly, does Struts2 automatically create an HTTP Session or do I need to explicitly create it. Early experimentation suggests that it's automatically created as I'm seeing the JSESSIONID parameter in the Urls generated without doing anything, but I'd like to be sure. Secondly I need to know when a session is ended. Is there an established Struts 2 practice for this or do I still create an HTTPSessionListener object and register it in web.xml as I would with a basic web-app. Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Newbie question about HTTP Sessions
Hello. A couple of newbie questions. Firstly, does Struts2 automatically create an HTTP Session or do I need to explicitly create it. Sessions are managed by the servlet-container. Struts does not need to create them. Early experimentation suggests that it's automatically created as I'm seeing the JSESSIONID parameter in the Urls generated without doing anything, but I'd like to be sure. Yes - you are right. The sessions are generated automatically by the container (tomcat, etc). Secondly I need to know when a session is ended. Is there an established Struts 2 practice for this or do I still create an HTTPSessionListener object and register it in web.xml as I would with a basic web-app. HTTPSessionListener? You can use --- code --- session-config session-timeout30/session-timeout /session-config --- code --- the timeout is given in minutes. after this time the session is destroyed. Piero. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Newbie question about HTTP Sessions
Secondly I need to know when a session is ended. Is there an established Struts 2 practice for this or do I still create an HTTPSessionListener object and register it in web.xml as I would with a basic web-app. HTTPSessionListener? You can use --- code --- session-config session-timeout30/session-timeout /session-config --- code --- the timeout is given in minutes. after this time the session is destroyed. Ups, sorry. Did not understand it right ;) If you need to know when a session is ended I would do it like in every other web application. Piero. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Newbie question about HTTP Sessions
Yes - you are right. The sessions are generated automatically by the container (tomcat, etc). Thanks. In a servlet based web-app I would create the session object programatticaly with httpServletRequest.getSession(true). I just wasn't sure if Struts 2 was creating the session for me since I appear not to have direct access to the httpRequest and httpResponse objects in my actions unless I specifically code for it through an interceptor. Secondly I need to know when a session is ended. Is there an established Struts 2 practice for this or do I still create an HTTPSessionListener object and register it in web.xml as I would with a basic web-app. HTTPSessionListener? A class that implements the HttpSessionListener interface has two methods, one of which is sessionDestroyed(HttpSessionEvent) that gets called when the container is about to destroy a session, in which I would put any session specific clean-up code if required. Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]