Example usage for javax.servlet.http HttpServletRequest getAttributeNames

List of usage examples for javax.servlet.http HttpServletRequest getAttributeNames

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getAttributeNames.

Prototype

public Enumeration<String> getAttributeNames();

Source Link

Document

Returns an Enumeration containing the names of the attributes available to this request.

Usage

From source file:sfw.tool.ServiceTool.java

public static void printAttributes(HttpServletRequest request) {
    Enumeration<String> enu = request.getAttributeNames();
    while (enu.hasMoreElements()) {
        String key = enu.nextElement();
        de.println(key + " : " + request.getAttribute(key) + " : "
                + request.getAttribute(key).getClass().getName());
    }//from  w ww .j a  v  a  2s. c o m
}

From source file:com.manydesigns.elements.servlet.ServletUtils.java

public static void dumpRequestAttributes(HttpServletRequest request) {
    Enumeration attNames = request.getAttributeNames();
    while (attNames.hasMoreElements()) {
        String attrName = (String) attNames.nextElement();
        Object attrValue = request.getAttribute(attrName);
        logger.info("{} = {}", attrName, attrValue);
    }/*from   ww w . jav a2s .c o  m*/
}

From source file:gov.nih.nci.cabig.ctms.web.WebTools.java

@SuppressWarnings({ "unchecked" })
public static SortedMap<String, Object> requestAttributesToMap(final HttpServletRequest request) {
    return namedAttributesToMap(request.getAttributeNames(), new AttributeAccessor() {
        public Object getAttribute(String name) {
            return request.getAttribute(name);
        }//from  w w w .  ja v a2s.  c  om
    });
}

From source file:org.mrgeo.services.ServletUtils.java

/**
 * Prints request attributes to the debug logger
 * @param request servlet request// w w w .  j av a 2s .  co m
 */
public static void printRequestAttributes(HttpServletRequest request) {
    @SuppressWarnings("rawtypes")
    Enumeration enAttr = request.getAttributeNames();
    while (enAttr.hasMoreElements()) {
        String attributeName = (String) enAttr.nextElement();
        log.debug("Attribute Name: {}, Value: {}", attributeName,
                (request.getAttribute(attributeName)).toString());
    }
}

From source file:mojo.view.util.DebugUtils.java

@SuppressWarnings("rawtypes")
public static void logRequestAttributes(HttpServletRequest req) {
    logger.debug("REQUEST ATTRIBUTES");
    logger.debug("------------------");

    Enumeration enums = req.getAttributeNames();

    while (enums.hasMoreElements()) {
        String attrName = (String) enums.nextElement();
        Object attrValue = req.getAttribute(attrName);
        StringBuilder sb = new StringBuilder();
        sb.append(attrName + ": " + attrValue);
        logger.debug(sb.toString());//from   ww  w.  j  ava  2  s. c  om
    }

    logger.debug("");
}

From source file:edu.utah.further.i2b2.hook.further.web.ServletUtil.java

/**
 * @param request/*from w  ww .j a  v  a2 s .  c  o  m*/
 */
public static void printRequestAttributes(final HttpServletRequest request) {
    log.debug("Request attributes:");
    final Enumeration<?> attributeNames = request.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        final String name = (String) attributeNames.nextElement();
        log.debug(name + " = " + request.getAttribute(name));
    }
}

From source file:org.craftercms.core.util.HttpServletUtils.java

public static Map<String, Object> createRequestAttributesMap(HttpServletRequest request) {
    Map<String, Object> attributesMap = new HashMap<String, Object>();
    for (Enumeration attributeNameEnum = request.getAttributeNames(); attributeNameEnum.hasMoreElements();) {
        String attributeName = (String) attributeNameEnum.nextElement();

        attributesMap.put(attributeName, request.getAttribute(attributeName));
    }/*from   w ww .  j a v a 2s . c  om*/

    return attributesMap;
}

From source file:edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils.java

/**
 * returns a table of the req attributes
 * @param req// ww  w  .  j av  a 2  s.c o m
 * @return
 */
public static String getRequestAttributes(HttpServletRequest req) {
    String val = "<table>";
    Enumeration names = req.getAttributeNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        val += "\n\t<tr><td>" + name + "</td><td><pre>";
        String value = null;
        try {
            Object obj = req.getAttribute(name);
            value = (obj instanceof Model || obj instanceof ModelCom) ? "[Jena model object]"
                    : (obj == null) ? "[null]" : StringEscapeUtils.escapeHtml(obj.toString());
        } catch (Exception ex) {
            value = "unable to get value";
        } catch (Error er) {
            value = "unable to get value";
        } catch (Throwable th) {
            value = "unable to get value";
        }
        val += value + "</pre></td></tr>\n";
    }
    return val + "</table>";
}

From source file:ste.web.beanshell.jetty.BeanShellUtils.java

public static void setup(final Interpreter interpreter, final HttpServletRequest request,
        final HttpServletResponse response) throws EvalError, IOException {
    ////from   ww  w  .j  av  a2s  .  c  o m
    // Set attributes as script variables
    //
    String k, key;
    for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) {
        k = (String) e.nextElement();
        key = normalizeVariableName(k);
        interpreter.set(key, request.getAttribute(k));
    }

    //
    // Set request parameters as script variables. Note that parameters
    // override attributes
    //
    for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
        k = (String) e.nextElement();
        key = normalizeVariableName(k);
        interpreter.set(key, request.getParameter(k));
    }

    interpreter.set(VAR_REQUEST, request);
    interpreter.set(VAR_RESPONSE, response);
    interpreter.set(VAR_SESSION, request.getSession(false));
    interpreter.set(VAR_OUT, response.getWriter());
    interpreter.set(VAR_LOG, log);
    if (hasJSONBody(request)) {
        interpreter.set(VAR_BODY, getJSONBody(request.getInputStream()));
    }
}

From source file:ubic.gemma.util.RequestUtil.java

/**
 * Stores request attributes in session/*from  www.  j a  va2s  .c  o  m*/
 * 
 * @param aRequest the current request
 */
public static void stowRequestAttributes(HttpServletRequest aRequest) {
    if (aRequest.getSession().getAttribute(STOWED_REQUEST_ATTRIBS) != null) {
        return;
    }

    Enumeration<String> e = aRequest.getAttributeNames();
    Map<String, Object> map = new HashMap<String, Object>();

    while (e.hasMoreElements()) {
        String name = e.nextElement();
        map.put(name, aRequest.getAttribute(name));
    }

    aRequest.getSession().setAttribute(STOWED_REQUEST_ATTRIBS, map);
}