LogoutAction.java
01 package com.bea.medrec.actions;
02 
03 import com.bea.medrec.utils.MedRecLog4jFactory;
04 import com.bea.medrec.utils.MedRecWebAppUtils;
05 import javax.servlet.http.HttpServletRequest;
06 import javax.servlet.http.HttpServletResponse;
07 import org.apache.log4j.Logger;
08 import org.apache.struts.action.ActionForm;
09 import org.apache.struts.action.ActionForward;
10 import org.apache.struts.action.ActionMapping;
11 import weblogic.servlet.security.ServletAuthentication;
12 
13 /**
14  <p>Login controller.  Handles all request during the logout
15  * process.</p>
16  *
17  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
18  */
19 public class LogoutAction extends PatientBaseAction {
20 
21   private static Logger logger = MedRecLog4jFactory.getLogger(LogoutAction.class.getName());
22 
23   /**
24    <p>Process the specified HTTP request, and create the corresponding HTTP
25    * response (or forward to another web component that will create it).
26    * Return an <code>ActionForward</code> instance describing where and how
27    * control should be forwarded.
28    <br>
29    * Invalidates session and redirects to MedRec homepage.
30    </p>
31    *
32    @param mapping  The ActionMapping used to select this instance
33    @param form  The optional ActionForm bean for this request (if any)
34    @param request  The HTTP request we are processing
35    @param response  The HTTP response we are creating
36    */
37   public ActionForward executeAction(ActionMapping mapping,
38                                      ActionForm form,
39                                      HttpServletRequest request,
40                                      HttpServletResponse response)
41       throws Exception {
42     logger.info("Logging out user.");
43 
44     logger.info("Invalidating session.");
45     ServletAuthentication.invalidateAll(request);
46 
47     // Return to MedRec start page.
48     return mapping.findForward("medrec.startpage");
49   }
50 
51 }