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