Java Code Examples for javax.servlet.ServletRequest#getAttributeNames()

The following examples show how to use javax.servlet.ServletRequest#getAttributeNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplicationRequest.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Set the request that we are wrapping.
 *
 * @param request The new wrapped request
 */
@Override
public void setRequest(ServletRequest request) {

    super.setRequest(request);

    // Initialize the attributes for this request
    synchronized (attributes) {
        attributes.clear();
        Enumeration<String> names = request.getAttributeNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            Object value = request.getAttribute(name);
            attributes.put(name, value);
        }
    }

}
 
Example 2
Source File: ApplicationRequest.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Set the request that we are wrapping.
 *
 * @param request The new wrapped request
 */
@Override
public void setRequest(ServletRequest request) {

    super.setRequest(request);

    // Initialize the attributes for this request
    synchronized (attributes) {
        attributes.clear();
        Enumeration<String> names = request.getAttributeNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            Object value = request.getAttribute(name);
            attributes.put(name, value);
        }
    }

}
 
Example 3
Source File: ApplicationRequest.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Set the request that we are wrapping.
 *
 * @param request The new wrapped request
 */
@Override
public void setRequest(ServletRequest request) {

    super.setRequest(request);

    // Initialize the attributes for this request
    synchronized (attributes) {
        attributes.clear();
        Enumeration<String> names = request.getAttributeNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            Object value = request.getAttribute(name);
            attributes.put(name, value);
        }
    }

}
 
Example 4
Source File: HttpUtil.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
private static void dumpParamsAndAttrs(final ServletRequest req, final StringBuilder stringBuilder) {

        stringBuilder.append(HttpParamsUtils.stringify("\nParameters\n", req.getParameterMap()));

        Enumeration attributeNames = req.getAttributeNames();
        final Map<String, String> map = new HashMap<>();
        while (attributeNames.hasMoreElements()) {
            final String key = (String) attributeNames.nextElement();
            map.put(key, String.valueOf(req.getAttribute(key)));
        }
        stringBuilder.append(HttpParamsUtils.stringify("\nAttributes\n", map));

    }
 
Example 5
Source File: ServletRequestHandler.java    From commons-jxpath with Apache License 2.0 5 votes vote down vote up
protected void collectPropertyNames(HashSet set, Object bean) {
    super.collectPropertyNames(set, bean);
    ServletRequestAndContext handle = (ServletRequestAndContext) bean;
    ServletRequest servletRequest = handle.getServletRequest();
    Enumeration e = servletRequest.getAttributeNames();
    while (e.hasMoreElements()) {
        set.add(e.nextElement());
    }
    e = servletRequest.getParameterNames();
    while (e.hasMoreElements()) {
        set.add(e.nextElement());
    }
}
 
Example 6
Source File: ServletAttrContainer.java    From scipio-erp with Apache License 2.0 votes vote down vote up
public static Enumeration<String> getAttributeNames(ServletRequest container) { return (container != null) ? container.getAttributeNames() : null; }