KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > LogOutAction


1 /*
2  * Copyright 2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.webapp.admin;
19
20
21 import java.io.IOException JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Locale JavaDoc;
25 import javax.servlet.ServletException JavaDoc;
26 import javax.servlet.http.HttpServletRequest JavaDoc;
27 import javax.servlet.http.HttpServletResponse JavaDoc;
28 import javax.servlet.http.HttpSession JavaDoc;
29 import org.apache.struts.action.Action;
30 import org.apache.struts.action.ActionErrors;
31 import org.apache.struts.action.ActionForm;
32 import org.apache.struts.action.ActionForward;
33 import org.apache.struts.action.ActionMapping;
34
35
36 /**
37  * Implementation of <strong>Action</strong> that logs out of the current
38  * session and returns to the main menu (which will trigger the login form).
39  *
40  * @author Craig R. McClanahan
41  * @version $Revision: 1.3 $ $Date: 2004/10/18 06:37:53 $
42  */

43
44 public final class LogOutAction extends Action {
45
46
47     // --------------------------------------------------------- Public Methods
48

49
50     /**
51      * Process the specified HTTP request, and create the corresponding HTTP
52      * response (or forward to another web component that will create it).
53      * Return an <code>ActionForward</code> instance describing where and how
54      * control should be forwarded, or <code>null</code> if the response has
55      * already been completed.
56      *
57      * @param mapping The ActionMapping used to select this instance
58      * @param actionForm The optional ActionForm bean for this request (if any)
59      * @param request The HTTP request we are processing
60      * @param response The HTTP response we are creating
61      *
62      * @exception IOException if an input/output error occurs
63      * @exception ServletException if a servlet exception occurs
64      */

65     public ActionForward execute(ActionMapping mapping,
66                                  ActionForm form,
67                                  HttpServletRequest JavaDoc request,
68                                  HttpServletResponse JavaDoc response)
69         throws IOException JavaDoc, ServletException JavaDoc {
70
71         // Invalidate the current session and create a new one
72
HttpSession JavaDoc session = request.getSession();
73         session.invalidate();
74         session = request.getSession(true);
75
76         // Forward control back to the main menu
77
return (mapping.findForward("Main Menu"));
78
79     }
80
81
82 }
83
Popular Tags