001 /* 002 * Copyright 2004 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package javax.servlet; 017 018 019 /** 020 * This is the event class for notifications of changes to the 021 * attributes of the servlet request in an application. 022 * @see ServletRequestAttributeListener 023 * @since Servlet 2.4 024 */ 025 026 public class ServletRequestAttributeEvent extends ServletRequestEvent { 027 private String name; 028 private Object value; 029 030 /** Construct a ServletRequestAttributeEvent giving the servlet context 031 * of this web application, the ServletRequest whose attributes are 032 * changing and the name and value of the attribute. 033 * 034 * @param sc the ServletContext that is sending the event. 035 * @param request the ServletRequest that is sending the event. 036 * @param name the name of the request attribute. 037 * @param value the value of the request attribute. 038 */ 039 public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) { 040 super(sc, request); 041 this.name = name; 042 this.value = value; 043 } 044 045 /** 046 * Return the name of the attribute that changed on the ServletRequest. 047 * 048 * @return the name of the changed request attribute 049 */ 050 public String getName() { 051 return this.name; 052 } 053 054 /** 055 * Returns the value of the attribute that has been added, removed or 056 * replaced. If the attribute was added, this is the value of the 057 * attribute. If the attribute was removed, this is the value of the 058 * removed attribute. If the attribute was replaced, this is the old 059 * value of the attribute. 060 * 061 * @return the value of the changed request attribute 062 */ 063 public Object getValue() { 064 return this.value; 065 } 066 }