1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.struts.tiles.actions;
21
22 import java.io.PrintWriter;
23
24 import javax.servlet.ServletContext;
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
27
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.tiles.DefinitionsFactory;
33 import org.apache.struts.tiles.TilesUtil;
34
35
36
37 /***
38 * <p>An <strong>Action</strong> that writes the
39 * definitions of the Tiles factory.
40 * Useful to check what is effectivly loaded in a
41 * Tiles factory
42 */
43
44 public class ViewDefinitionsAction extends Action {
45
46 /***
47 * Process the specified HTTP request, and create the corresponding HTTP
48 * response (or forward to another web component that will create it),
49 * with provision for handling exceptions thrown by the business logic.
50 *
51 * @param mapping The ActionMapping used to select this instance
52 * @param form The optional ActionForm bean for this request (if any)
53 * @param request The HTTP request we are processing
54 * @param response The HTTP response we are creating
55 *
56 * @exception Exception if the application business logic throws
57 * an exception
58 * @since Struts 1.1
59 */
60 public ActionForward execute(ActionMapping mapping,
61 ActionForm form,
62 HttpServletRequest request,
63 HttpServletResponse response)
64 throws Exception
65 {
66 response.setContentType("text/plain");
67 PrintWriter writer = response.getWriter();
68
69 try {
70 ServletContext context = getServlet().getServletContext();
71 DefinitionsFactory factory =
72 TilesUtil.getDefinitionsFactory(request, context );
73 writer.println( factory.toString() );
74 } catch (Exception e) {
75 writer.println("FAIL - " + e.toString());
76 getServlet().log("ReloadAction", e);
77 }
78
79 writer.flush();
80 writer.close();
81
82 return (null);
83
84 }
85
86 }