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