I agree too that (generally speaking) we must introduce the least possible quantity of scripting into JSP pages as we can, so we honor the MVC architecture, however, in this particular case (invalidating the session), I don't understand why would be better to do it in the action class rather than in the JSP page for non-small apps.
In addition, the "preferred" way of manipulating the session in S2 is by implementing SessionAware interface, and what is really injected into the action is a Map (I guess that it is this way so as actions will be more unit test friendly). Take a look to the code to invalidate a session: http://struts.apache.org/2.0.9/docs/how-do-we-get-invalidate-the-session.html Now regardless of if the app is small or very large, I don't know any use case scenario where invalidating the session inside the action class would produce less counter-productive effects than doing it in the JSP page (beyond of course purist arguments like "it breaks our system architecture document"). 2007/9/12, Alvaro Sanchez-Mariscal <[EMAIL PROTECTED]>: > I keep on saying that you can perform exactly the same with > LogoutAction, but keeping away code from JSP. > > However, I agree that in very small apps is ok to do a little scripting. > > Alvaro. > > On 9/12/07, Gabriel Belingueres <[EMAIL PROTECTED]> wrote: > > I'm not a purist myself, so it may break the MVC model somewhere, but > > (at lest in the apps I coded) I didn't find any use case that forced > > my to invalidate the session into a Logout action class. > > > > In addition, I like to present messages like "Thank you <Your Name > > here>" and this information is usually in session scope, so > > invalidating the session in the action class would force me to > > transfer this information into request scope just for showing in the > > logout page. > > > > 2007/9/11, Ray Clough <[EMAIL PROTECTED]>: > > > The only thing "wrong" with it is that now you are putting application > > > control logic in a jsp page, which is 'OK' for small apps, and is > > > probably 'OK' in this particular instance if there are no complicating > > > factors. However, for purists, it IS putting control logic in a jsp > > > page, which purists do not view as 'OK' (speaking as a purist myself, > > > while acknowledging this as a possible character flaw.). > > > - Ray Clough > > > > > > > > > > ----- Original Message ----- > > > > From: "Gabriel Belingueres" <[EMAIL PROTECTED]> > > > > To: "Struts Users Mailing List" <user@struts.apache.org> > > > > Subject: Re: How to invalidate a session in struts 2.0 > > > > Date: Tue, 11 Sep 2007 16:16:41 -0300 > > > > > > > > > > > > Personally, I use the good old > > > > > > > > <% session.invalidate(); %> > > > > > > > > as the last instruction of my logout.jsp page. > > > > > > > > AFAIK, to invalidate the session inside an action, you must downcast > > > > the session Map (from the SessionAware interface) to a SessionMap > > > > class, which seems little awkward to me. > > > > > > > > Besides, using session.invalidate() doesn't seems to me like an > > > > anti-pattern or something wrong. > > > > > > > > Gabriel > > > > > > > > 2007/9/11, illusion <[EMAIL PROTECTED]>: > > > > > > > > > > Hey, > > > > > > > > > > How to invalidate a Http Sesssion in struts 2.0? There is a > > > > > SessionMap > > > > > class which asks for a httpservletrequest as a parameter, and has an > > > > > invalidate method for the http session, not sure how this works. > > > > > > > > > > thanks in advance for your assistance > > > > > -- > > > > > View this message in context: > > > > > http://www.nabble.com/How-to-invalidate-a-session-in-struts-2.0-tf4424331.html#a12620475 > > > > > Sent from the Struts - User mailing list archive at Nabble.com. > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > - Ray Clough > > > [EMAIL PROTECTED] > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Alvaro Sanchez-Mariscal Arnaiz > Java EE Architect & Instructor > [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]