In addition to my earlier response. The problem is,. you actually do
closed your session because if you try to invalidate the session again right
after your first invalidate you will get an invalidStateException (or
something)..... but if you do a forward to the next resource ... for some
reason the old session will get reactivate again.... the solution is to do a
redirect instead ...
danny
> -----Original Message-----
> From: Adam Hardy [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, May 14, 2002 5:12 AM
> To: Struts Users Mailing List
> Subject: Re: LogoutAction
>
> how do you know it�s not closing the session? What is happening instead?
>
> Adam
>
> Villegas, Courtney wrote:
>
> >I am having troubles with the logout action that I have written. It
> directs
> >me to the correct page, but does not actually log the user out and close
> the
> >session. I have attached my action and the info from my struts-config
> file.
> >I am calling session.invalidate() incorrectly?
> >
> >Thanks
> >Courtney
> >
> > <!--************************************* Logoff Action
> >*************************************-->
> > <action path="/logoff"
> > type="org.trimet.security.actions.LogoffAction"
> > scope="request">
> > <forward name="success" path="/jsp/ctest.jsp"/>
> > </action>
> >
> >package org.trimet.security.actions;
> >
> >import java.io.IOException;
> >import java.lang.reflect.InvocationTargetException;
> >import java.util.Locale;
> >import java.util.Vector;
> >import javax.servlet.RequestDispatcher;
> >import javax.servlet.ServletException;
> >import javax.servlet.http.HttpServletRequest;
> >import javax.servlet.http.HttpSession;
> >import javax.servlet.http.HttpServletResponse;
> >import org.apache.struts.action.Action;
> >import org.apache.struts.action.ActionForm;
> >import org.apache.struts.action.ActionForward;
> >import org.apache.struts.action.ActionMapping;
> >import org.apache.struts.action.ActionServlet;
> >import org.apache.struts.util.MessageResources;
> >import org.apache.commons.beanutils.PropertyUtils;
> >
> >import org.trimet.security.states.Constants;
> >import org.trimet.security.states.User;
> >
> >/**
> > * Implementation of <strong>Action</strong> that logs user out of
> current
> >session
> > *
> > * @author Courtney S. Villegas
> > * @version $Revision: 1.0 $ $Date: 2002/05/13 03:03:00 $
> > */
> >
> >public final class LogoffAction extends Action {
> >
> >
> > // --------------------------------------------------------- Public
> >Methods
> >
> >
> > /**
> > * Process the specified HTTP request, and create the corresponding
> HTTP
> > * response (or forward to another web component that will create
> it).
> > * Return an <code>ActionForward</code> instance describing where and
> >how
> > * control should be forwarded, or <code>null</code> if the response
> has
> > * already been completed.
> > *
> > * @param mapping The ActionMapping used to select this instance
> > * @param actionForm The optional ActionForm bean for this request
> (if
> >any)
> > * @param request The HTTP request we are processing
> > * @param response The HTTP response we are creating
> > *
> > * @exception IOException if an input/output error occurs
> > * @exception ServletException if a servlet exception occurs
> > */
> > public ActionForward perform(ActionMapping mapping,
> > ActionForm form,
> > HttpServletRequest request,
> > HttpServletResponse response)
> > throws IOException, ServletException {
> >
> > // Extract attributes we will need
> > Locale locale = getLocale(request);
> > MessageResources messages = getResources();
> > HttpSession session = request.getSession();
> > String action = request.getParameter("Load");
> > if (action == null)
> > action = "Load";
> > if (servlet.getDebug() >= 1)
> > servlet.log("LogoffAction: Processing " + action +
> > " action");
> >
> > // Is there a currently logged on user?
> > User user = (User) session.getAttribute(Constants.USER_KEY);
> > if (user == null) {
> > if (servlet.getDebug() >= 1)
> > servlet.log(" User is not logged on in session "
> > + session.getId());
> > return (servlet.findForward("logon"));
> > }
> >
> >
> > // Forward control to the GISAppDev page
> > if (servlet.getDebug() >= 1)
> > servlet.log(" Forwarding to 'GIS App Dev' page");
> > user=null;
> > session.invalidate();
> > return (mapping.findForward("success"));
> >
> > }
> >
> >
> >}
> >
> >--
> >To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>