1 16 17 package examples.app3; 18 19 import java.io.IOException ; 20 import java.util.Hashtable ; 21 import java.util.Locale ; 22 import java.util.Vector ; 23 import javax.servlet.RequestDispatcher ; 24 import javax.servlet.ServletException ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpSession ; 27 import javax.servlet.http.HttpServletResponse ; 28 import org.apache.struts.action.Action; 29 import org.apache.struts.action.ActionForm; 30 import org.apache.struts.action.ActionForward; 31 import org.apache.struts.action.ActionMapping; 32 import org.apache.struts.action.ActionServlet; 33 import org.apache.struts.util.MessageResources; 34 35 36 44 45 public final class LogoffAction extends Action 46 { 47 48 50 62 public ActionForward execute(ActionMapping mapping, 63 ActionForm form, 64 HttpServletRequest request, 65 HttpServletResponse response) 66 throws IOException , ServletException 67 { 68 69 HttpSession session = request.getSession(); 71 LogonForm user = (LogonForm) 72 session.getAttribute(Constants.USER_KEY); 73 74 if (user != null) 76 { 77 StringBuffer message = new StringBuffer ("LogoffAction: User '"); 78 message.append(user.getUsername()); 79 message.append("' logged off in session "); 80 message.append(session.getId()); 81 servlet.log(message.toString()); 82 } 83 84 else 85 { 86 87 StringBuffer message = new StringBuffer ("LogoffAction: User '"); 88 message.append(session.getId()); 89 servlet.log(message.toString()); 90 } 91 92 session.removeAttribute(Constants.USER_KEY); 94 session.invalidate(); 95 96 return (mapping.findForward(Constants.CONTINUE)); 98 99 } 100 101 } | Popular Tags |