1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts.apps.mailreader.actions;
23
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.apps.mailreader.Constants;
28 import org.apache.struts.apps.mailreader.dao.User;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
32 import javax.servlet.http.HttpSession;
33
34
35
36
37
38
39
40
41 public final class LogoffAction extends BaseAction {
42
43
44 public ActionForward execute(
45 ActionMapping mapping,
46 ActionForm form,
47 HttpServletRequest request,
48 HttpServletResponse response)
49 throws Exception {
50
51
52 HttpSession session = request.getSession();
53 User user = doGetUser(session);
54 if (user != null) {
55 if (log.isDebugEnabled()) {
56 log.debug(
57 "LogoffAction: User '"
58 + user.getUsername()
59 + "' logged off in session "
60 + session.getId());
61 }
62 } else {
63 if (log.isDebugEnabled()) {
64 log.debug(
65 "LogoffActon: User logged off in session " +
66 session.getId());
67 }
68 }
69
70
71 session.removeAttribute(Constants.SUBSCRIPTION_KEY);
72 session.removeAttribute(Constants.USER_KEY);
73 session.invalidate();
74
75
76 return doFindSuccess(mapping);
77
78 }
79
80 }