KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > MvcAction


1 import java.io.*;
2 import javax.servlet.*;
3 import javax.servlet.http.*;
4
5 import jodd.servlet.*;
6
7
8 public class MvcAction extends ActionServlet {
9
10     /**
11      * Main entry point for the framework actions. No redirection and forwarding
12      * is allowed here - instead, a string is returned that represents
13      * 'mapping', i.e. key from the configuration file that defines where to
14      * forward or redirect after this method finishes.
15      *
16      * @param request
17      * @param response
18      *
19      * @return
20      * @exception IOException
21      * @exception ServletException
22      */

23     public String doAction(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
24         System.out.println("---------------------");
25         System.out.println("FooAction.doAction()");
26         
27         String mapping = invokeAction(request, response);
28         System.out.println("invoke result: " + mapping);
29
30         return mapping;
31     }
32
33
34     /**
35      * This is an action handler that returns bad mapping.
36      *
37      * @param request
38      * @param response
39      *
40      * @return
41      * @exception IOException
42      * @exception ServletException
43      */

44     public String bad(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
45         System.out.println(">ACTION:bad");
46         return "notok";
47     }
48
49     /**
50      * This is an action handler that returns good mapping. These action handlers are
51      * invoked by doAction() method and they usually returns a String, as if they
52      * were doActions itself, although it is not necessary.
53      *
54      * @param request
55      * @param response
56      *
57      * @return
58      * @exception IOException
59      * @exception ServletException
60      */

61     public String good(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
62         System.out.println(">ACTION:good");
63         System.out.println("param: " + getActionParameter(request, "nnaammee"));
64         System.out.println("action path: " + getActionPath(request));
65         System.out.println("forward path: " + getActionForwardPath(request, "ok"));
66         System.out.println("action type: " + getActionType(request));
67         System.out.println("action method: " +getActionMethodName(request));
68         return "ok";
69     }
70
71
72     /**
73      * Reloads XML configuration file of the controller without restarting the
74      * application.
75      *
76      * @param request
77      * @param response
78      *
79      * @exception IOException
80      * @exception ServletException
81      */

82     public String reload(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
83         System.out.println(">ACTION:reload");
84         ActionController controller = getController();
85         controller.reload();
86         return "";
87
88     }
89 }
90
91
Popular Tags