View Javadoc

1   
2   
3   /*
4    * The contents of this file are subject to the terms
5    * of the Common Development and Distribution License
6    * (the "License").  You may not use this file except
7    * in compliance with the License.
8    *
9    * You can obtain a copy of the license at
10   * glassfish/bootstrap/legal/CDDLv1.0.txt or
11   * https://glassfish.dev.java.net/public/CDDLv1.0.html.
12   * See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * When distributing Covered Code, include this CDDL
16   * HEADER in each file and include the License file at
17   * glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable,
18   * add the following below this CDDL HEADER, with the
19   * fields enclosed by brackets "[]" replaced with your
20   * own identifying information: Portions Copyright [yyyy]
21   * [name of copyright owner]
22   *
23   * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24   *
25   * Portions Copyright Apache Software Foundation.
26   */
27  
28  package javax.servlet;
29  
30  
31      /** 
32        * This is the event class for notifications of changes to the 
33        * attributes of the servlet request in an application.
34        * @see ServletRequestAttributeListener
35        * @since	Servlet 2.4
36        */
37  
38  public class ServletRequestAttributeEvent extends ServletRequestEvent { 
39      private String name;
40      private Object value;
41  
42       /** Construct a ServletRequestAttributeEvent giving the servlet context
43        * of this web application, the ServletRequest whose attributes are
44        * changing and the name and value of the attribute.
45        *
46        * @param sc		the ServletContext that is sending the event.
47        * @param request		the ServletRequest that is sending the event.
48        * @param name		the name of the request attribute.
49        * @param value		the value of the request attribute.
50        */
51      public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
52          super(sc, request);
53          this.name = name;
54          this.value = value;
55      }
56  
57      /**
58        * Return the name of the attribute that changed on the ServletRequest.
59        *
60        * @return		the name of the changed request attribute
61        */
62      public String getName() {
63          return this.name;
64      }
65  
66      /**
67        * Returns the value of the attribute that has been added, removed or 
68        * replaced. If the attribute was added, this is the value of the 
69        * attribute. If the attribute was removed, this is the value of the 
70        * removed attribute. If the attribute was replaced, this is the old 
71        * value of the attribute.
72        *
73        * @return		the value of the changed request attribute
74        */
75      public Object getValue() {
76          return this.value;   
77      }
78  }