~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to src/examples/org/apache/struts/webapp/dispatch/MappingDispatchExampleAction.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: MappingDispatchExampleAction.java 383716 2006-03-07 00:04:15Z niallp $ 
 
3
 *
 
4
 * Copyright 2006 The Apache Software Foundation.
 
5
 * 
 
6
 * Licensed under the Apache License, Version 2.0 (the "License");
 
7
 * you may not use this file except in compliance with the License.
 
8
 * You may obtain a copy of the License at
 
9
 * 
 
10
 *      http://www.apache.org/licenses/LICENSE-2.0
 
11
 * 
 
12
 * Unless required by applicable law or agreed to in writing, software
 
13
 * distributed under the License is distributed on an "AS IS" BASIS,
 
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
 * See the License for the specific language governing permissions and
 
16
 * limitations under the License.
 
17
 */
 
18
package org.apache.struts.webapp.dispatch;
 
19
 
 
20
import java.util.Map;
 
21
import java.util.HashMap;
 
22
import javax.servlet.http.HttpServletRequest;
 
23
import javax.servlet.http.HttpServletResponse;
 
24
import org.apache.struts.actions.MappingDispatchAction;
 
25
import org.apache.struts.action.ActionForm;
 
26
import org.apache.struts.action.ActionForward;
 
27
import org.apache.struts.action.ActionMapping;
 
28
import org.apache.struts.action.ActionMessage;
 
29
import org.apache.struts.action.ActionMessages;
 
30
 
 
31
/**
 
32
 * Example DispatchAction.
 
33
 *
 
34
 * @version $Rev: 383716 $ $Date: 2006-03-07 00:04:15 +0000 (Tue, 07 Mar 2006) $
 
35
 */
 
36
public class MappingDispatchExampleAction extends MappingDispatchAction {
 
37
 
 
38
    private Map keyMethodMap = new HashMap();
 
39
    private int fooCount;
 
40
    private int barCount;
 
41
 
 
42
    /**
 
43
     * Example "foo" method.
 
44
     *
 
45
     * @param mapping The ActionMapping used to select this instance
 
46
     * @param form The optional ActionForm bean for this request
 
47
     * @param request The servlet request we are processing
 
48
     * @param response The servlet response we are creating
 
49
     *
 
50
     * @exception Exception if business logic throws an exception
 
51
     */
 
52
    public ActionForward doFoo(ActionMapping mapping,
 
53
                               ActionForm form,
 
54
                               HttpServletRequest request,
 
55
                               HttpServletResponse response)
 
56
        throws Exception {
 
57
 
 
58
        fooCount++;
 
59
 
 
60
        ActionMessages messages = new ActionMessages();
 
61
        messages.add("foo", new ActionMessage("count.foo.message", fooCount+""));
 
62
        saveMessages(request, messages);
 
63
 
 
64
        return (mapping.findForward("success"));
 
65
 
 
66
    }
 
67
 
 
68
    /**
 
69
     * Example "bar" method.
 
70
     *
 
71
     * @param mapping The ActionMapping used to select this instance
 
72
     * @param form The optional ActionForm bean for this request
 
73
     * @param request The servlet request we are processing
 
74
     * @param response The servlet response we are creating
 
75
     *
 
76
     * @exception Exception if business logic throws an exception
 
77
     */
 
78
    public ActionForward doBar(ActionMapping mapping,
 
79
                               ActionForm form,
 
80
                               HttpServletRequest request,
 
81
                               HttpServletResponse response)
 
82
        throws Exception {
 
83
        barCount++;
 
84
 
 
85
        ActionMessages messages = new ActionMessages();
 
86
        messages.add("bar", new ActionMessage("count.bar.message", barCount+""));
 
87
        saveMessages(request, messages);
 
88
 
 
89
        return (mapping.findForward("success"));
 
90
 
 
91
    }
 
92
 
 
93
}