KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > admin > controller > DisplayMainMenuAction


1 package com.quikj.application.communicator.admin.controller;
2
3 import java.io.IOException JavaDoc;
4 import java.util.Locale JavaDoc;
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.http.HttpServletResponse JavaDoc;
8 import org.apache.struts.action.Action;
9 import org.apache.struts.action.ActionError;
10 import org.apache.struts.action.ActionErrors;
11 import org.apache.struts.action.ActionForm;
12 import org.apache.struts.action.ActionForward;
13 import org.apache.struts.action.ActionMapping;
14 import java.sql.*;
15
16 /**
17  * Implementation of <strong>Action</strong> that validates a user logon.
18  * Based on Apache Struts framework.
19  *
20  * @author Vinod Batra
21  * @version $Revision: 1.3 $ $Date: 2004/05/03 11:09:17 $
22  */

23
24 public final class DisplayMainMenuAction extends Action
25 {
26     /**
27      * Process the specified HTTP request, and create the corresponding HTTP
28      * response (or forward to another web component that will create it).
29      * Return an <code>ActionForward</code> instance describing where and how
30      * control should be forwarded, or <code>null</code> if the response has
31      * already been completed.
32      *
33      * @param mapping The ActionMapping used to select this instance
34      * @param actionForm The optional ActionForm bean for this request (if any)
35      * @param request The HTTP request we are processing
36      * @param response The HTTP response we are creating
37      *
38      * @exception IOException if an input/output error occurs
39      * @exception ServletException if a servlet exception occurs
40      */

41     public ActionForward execute(ActionMapping mapping,
42     ActionForm form,
43     HttpServletRequest JavaDoc request,
44     HttpServletResponse JavaDoc response)
45     throws IOException JavaDoc, ServletException JavaDoc
46     {
47         // Extract attributes we will need
48
Locale JavaDoc locale = getLocale(request);
49         ActionErrors errors = new ActionErrors();
50         
51         // first check if the user has a connection
52
Connection c = (Connection)request.getSession().getAttribute("connection");
53         if (c == null)
54         {
55             errors.add(ActionErrors.GLOBAL_ERROR,
56             new ActionError("error.not.logged.in"));
57             saveErrors(request, errors);
58             return mapping.findForward("logon");
59         }
60                 
61         return (new ActionForward(mapping.getInput()));
62     }
63 }
64
Popular Tags