~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to src/share/org/apache/struts/tiles/actions/ViewDefinitionsAction.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/ViewDefinitionsAction.java,v 1.10 2004/03/14 06:23:46 sraeburn Exp $
 
3
 * $Revision: 1.10 $
 
4
 * $Date: 2004/03/14 06:23:46 $
 
5
 *
 
6
 * Copyright 1999-2004 The Apache Software Foundation.
 
7
 * 
 
8
 * Licensed under the Apache License, Version 2.0 (the "License");
 
9
 * you may not use this file except in compliance with the License.
 
10
 * You may obtain a copy of the License at
 
11
 * 
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
14
 * Unless required by applicable law or agreed to in writing, software
 
15
 * distributed under the License is distributed on an "AS IS" BASIS,
 
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
17
 * See the License for the specific language governing permissions and
 
18
 * limitations under the License.
 
19
 */
 
20
 
 
21
 
 
22
package org.apache.struts.tiles.actions;
 
23
 
 
24
import java.io.PrintWriter;
 
25
 
 
26
import javax.servlet.ServletContext;
 
27
import javax.servlet.http.HttpServletRequest;
 
28
import javax.servlet.http.HttpServletResponse;
 
29
 
 
30
import org.apache.struts.action.Action;
 
31
import org.apache.struts.action.ActionForm;
 
32
import org.apache.struts.action.ActionForward;
 
33
import org.apache.struts.action.ActionMapping;
 
34
import org.apache.struts.tiles.DefinitionsFactory;
 
35
import org.apache.struts.tiles.TilesUtil;
 
36
 
 
37
 
 
38
 
 
39
/**
 
40
 * <p>An <strong>Action</strong> that writes the
 
41
 * definitions of the Tiles factory.
 
42
 * Useful to check what is effectivly loaded in a
 
43
 * Tiles factory
 
44
 */
 
45
 
 
46
public class ViewDefinitionsAction extends Action {
 
47
 
 
48
    /**
 
49
     * Process the specified HTTP request, and create the corresponding HTTP
 
50
     * response (or forward to another web component that will create it),
 
51
     * with provision for handling exceptions thrown by the business logic.
 
52
     *
 
53
     * @param mapping The ActionMapping used to select this instance
 
54
     * @param form The optional ActionForm bean for this request (if any)
 
55
     * @param request The HTTP request we are processing
 
56
     * @param response The HTTP response we are creating
 
57
     *
 
58
     * @exception Exception if the application business logic throws
 
59
     *  an exception
 
60
     * @since Struts 1.1
 
61
     */
 
62
    public ActionForward execute(ActionMapping mapping,
 
63
                                 ActionForm form,
 
64
                                 HttpServletRequest request,
 
65
                                 HttpServletResponse response)
 
66
        throws Exception
 
67
    {
 
68
        response.setContentType("text/plain");
 
69
        PrintWriter writer = response.getWriter();
 
70
 
 
71
        try {
 
72
          ServletContext context = getServlet().getServletContext();
 
73
            DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context );
 
74
            writer.println( factory.toString() );
 
75
        } catch (Exception e) {
 
76
            writer.println("FAIL - " + e.toString());
 
77
            getServlet().log("ReloadAction", e);
 
78
        }
 
79
 
 
80
        writer.flush();
 
81
        writer.close();
 
82
 
 
83
        return (null);
 
84
 
 
85
    }
 
86
 
 
87
}
 
88