Example usage for javax.servlet ServletRequestAttributeListener attributeRemoved

List of usage examples for javax.servlet ServletRequestAttributeListener attributeRemoved

Introduction

In this page you can find the example usage for javax.servlet ServletRequestAttributeListener attributeRemoved.

Prototype

default public void attributeRemoved(ServletRequestAttributeEvent srae) 

Source Link

Document

Receives notification that an attribute has been removed from the ServletRequest.

Usage

From source file:org.apache.coyote.tomcat5.CoyoteRequest.java

/**
 * Remove the specified request attribute if it exists.
 *
 * @param name Name of the request attribute to remove
 *///from  w  ww . j ava  2  s. c om
public void removeAttribute(String name) {
    Object value = null;
    boolean found = false;

    // Remove the specified attribute
    // Check for read only attribute
    // requests are per thread so synchronization unnecessary
    if (readOnlyAttributes.containsKey(name)) {
        return;
    }
    found = attributes.containsKey(name);
    if (found) {
        value = attributes.get(name);
        attributes.remove(name);
    } else {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context.getServletContext(),
            getRequest(), name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletRequestAttributeListener))
            continue;
        ServletRequestAttributeListener listener = (ServletRequestAttributeListener) listeners[i];
        try {
            listener.attributeRemoved(event);
        } catch (Throwable t) {
            log(sm.getString("coyoteRequest.attributeEvent"), t);
            // Error valve will pick this execption up and display it to user
            attributes.put(Globals.EXCEPTION_ATTR, t);
        }
    }
}

From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java

/**
 * Notify interested listeners that attribute has been removed. ?
 *//*from   w w  w. j av  a2s. co m*/
private void notifyAttributeRemoved(String name, Object value) {
    if (_requestAttributeListeners != null && !_requestAttributeListeners.isEmpty()) {
        final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(servletContext, this, name,
                value);

        for (ServletRequestAttributeListener listener : _requestAttributeListeners) {
            listener.attributeRemoved(event);
        }
    }
}