FileDocCategorySizeDatePackage
LogoffAction.javaAPI DocExample5954Sun Mar 21 14:07:12 GMT 2004org.apache.struts.webapp.example

LogoffAction

public final class LogoffAction extends org.apache.struts.action.Action
Implementation of Action that processes a user logoff.
struts.action
path="/logoff"
struts.action-forward
name="success" path="/index.jsp"
author
Craig R. McClanahan
version
$Revision: 1.7 $ $Date: 2003/01/11 03:08:23 $

Fields Summary
private Log
log
The Log instance for this application.
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it). Return an ActionForward instance describing where and how control should be forwarded, or null 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
Exception if business logic throws an exception



    // --------------------------------------------------------- Public Methods


                                                                                               
       
				  
				  
				  
	  

	// Extract attributes we will need
	Locale locale = getLocale(request);
	MessageResources messages = getResources(request);
	HttpSession session = request.getSession();
	User user = (User) session.getAttribute(Constants.USER_KEY);

	// Process this user logoff
	if (user != null) {
            if (log.isDebugEnabled()) {
                log.debug("LogoffAction: User '" + user.getUsername() +
                          "' logged off in session " + session.getId());
            }
	} else {
            if (log.isDebugEnabled()) {
                log.debug("LogoffActon: User logged off in session " +
                          session.getId());
            }
	}
	session.removeAttribute(Constants.SUBSCRIPTION_KEY);
	session.removeAttribute(Constants.USER_KEY);
	session.invalidate();

	// Forward control to the specified success URI
	return (mapping.findForward("success"));