List of usage examples for javax.servlet.http HttpServletRequest getAttributeNames
public Enumeration<String> getAttributeNames();
Enumeration
containing the names of the attributes available to this request. From source file:org.trimou.spring.web.view.TrimouView.java
private void exposeRequestAttributesAsModel(Map<String, Object> model, HttpServletRequest request) { if (request == null || request.getAttributeNames() == null) { return;//from w w w .j a v a 2 s . c o m } Enumeration attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String attributeName = (String) attributeNames.nextElement(); model.put(attributeName, request.getAttribute(attributeName)); } }
From source file:org.jboss.dashboard.ui.controller.ControllerServletHelper.java
public void clearThreadLocal(HttpServletRequest request, HttpServletResponse response) { Enumeration en = request.getAttributeNames(); while (en.hasMoreElements()) { String name = (String) en.nextElement(); Object obj = request.getAttribute(name); if (obj instanceof FactoryLifecycle) { try { ((FactoryLifecycle) obj).shutdown(); } catch (Exception e) { log.error("Error: ", e); }//from ww w .ja v a 2s . c om } } RequestContext.destroy(); }
From source file:org.apache.nutch.webapp.controller.NutchController.java
/** * Log request attributes. used for debugging * /*from w w w . j a v a 2 s . c o m*/ * @param request */ void logRequestAttributes(HttpServletRequest request) { Enumeration e = request.getAttributeNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); LOG.info("request attrs:" + name + " = " + request.getAttribute(name)); } }
From source file:org.toobsframework.pres.util.ParameterUtil.java
public static Map buildParameterMap(HttpServletRequest request, boolean compCall) { Map params = new HashMap(); HttpSession session = request.getSession(); Enumeration attributes = session.getAttributeNames(); // Session has lowest priority while (attributes.hasMoreElements()) { String thisAttribute = (String) attributes.nextElement(); //if (session.getAttribute(thisAttribute) instanceof String) { params.put(thisAttribute, session.getAttribute(thisAttribute)); //}/*from w w w. j a v a 2 s . com*/ } // Parameters next highest params.putAll(request.getParameterMap()); // Attributes rule all attributes = request.getAttributeNames(); while (attributes.hasMoreElements()) { String thisAttribute = (String) attributes.nextElement(); if (!excludedParameters.contains(thisAttribute)) { if (log.isDebugEnabled()) { log.debug("Putting " + thisAttribute + " As " + request.getAttribute(thisAttribute)); } params.put(thisAttribute, request.getAttribute(thisAttribute)); } } params.put("httpQueryString", request.getQueryString()); if (compCall && request.getMethod().equals("POST")) { StringBuffer qs = new StringBuffer(); Iterator iter = request.getParameterMap().entrySet().iterator(); int i = 0; while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String[] value = (String[]) entry.getValue(); for (int j = 0; j < value.length; j++) { if (i > 0) qs.append("&"); qs.append(key).append("=").append(value[j]); i++; } } params.put("httpQueryString", qs.toString()); } return params; }
From source file:io.restassured.module.mockmvc.http.AttributeController.java
@RequestMapping(value = "/attribute", method = GET, produces = APPLICATION_JSON_VALUE) public @ResponseBody String attribute(HttpServletRequest request) { Collection<String> attributes = new ArrayList<String>(); for (String attributeName : Collections.list(request.getAttributeNames())) { attributes.add("\"" + attributeName + "\": \"" + request.getAttribute(attributeName) + "\""); }// w w w . j av a 2 s. com return "{" + StringUtils.join(attributes, ", ") + "}"; }
From source file:org.kuali.kfs.kns.util.WebUtils.java
/** * Iterates through and logs (at the given level) all attributes and * parameters of the given request onto the given Logger * * @param request/*from w ww .jav a 2s. c o m*/ * @param logger */ public static void logRequestContents(Logger logger, Level level, HttpServletRequest request) { if (logger.isEnabled(level)) { logger.log(level, "--------------------"); logger.log(level, "HttpRequest attributes:"); for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) { String attrName = (String) e.nextElement(); Object attrValue = request.getAttribute(attrName); if (attrValue.getClass().isArray()) { logCollection(logger, level, attrName, Arrays.asList((Object[]) attrValue)); } else if (attrValue instanceof Collection) { logCollection(logger, level, attrName, (Collection) attrValue); } else if (attrValue instanceof Map) { logMap(logger, level, attrName, (Map) attrValue); } else { logObject(logger, level, attrName, attrValue); } } logger.log(level, "--------------------"); logger.log(level, "HttpRequest parameters:"); for (Enumeration i = request.getParameterNames(); i.hasMoreElements();) { String paramName = (String) i.nextElement(); String[] paramValues = (String[]) request.getParameterValues(paramName); logArray(logger, level, paramName, paramValues); } logger.log(level, "--------------------"); } }
From source file:org.kuali.rice.kns.util.WebUtils.java
/** * Iterates through and logs (at the given level) all attributes and * parameters of the given request onto the given Logger * /*w w w .ja v a 2 s .co m*/ * @param request * @param logger */ public static void logRequestContents(Logger logger, Level level, HttpServletRequest request) { if (logger.isEnabledFor(level)) { logger.log(level, "--------------------"); logger.log(level, "HttpRequest attributes:"); for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) { String attrName = (String) e.nextElement(); Object attrValue = request.getAttribute(attrName); if (attrValue.getClass().isArray()) { logCollection(logger, level, attrName, Arrays.asList((Object[]) attrValue)); } else if (attrValue instanceof Collection) { logCollection(logger, level, attrName, (Collection) attrValue); } else if (attrValue instanceof Map) { logMap(logger, level, attrName, (Map) attrValue); } else { logObject(logger, level, attrName, attrValue); } } logger.log(level, "--------------------"); logger.log(level, "HttpRequest parameters:"); for (Enumeration i = request.getParameterNames(); i.hasMoreElements();) { String paramName = (String) i.nextElement(); String[] paramValues = (String[]) request.getParameterValues(paramName); logArray(logger, level, paramName, paramValues); } logger.log(level, "--------------------"); } }
From source file:com.redhat.rhn.frontend.servlets.DumpFilter.java
private void logAttributes(HttpServletRequest req) { Enumeration items = req.getAttributeNames(); while (items.hasMoreElements()) { String name = (String) items.nextElement(); Object obj = req.getAttribute(name); if (obj != null) { log.debug("Attribute: name [" + name + "] value [" + ReflectionToStringBuilder.toString(obj) + "]"); } else {// ww w .j a va 2 s. c o m log.debug("Attribute: name [" + name + "] value [null]"); } } }
From source file:fi.csc.emrex.smp.JsonController.java
private void printAttributes(HttpServletRequest request) { if (request != null) { final Enumeration<String> attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { final String name = attributeNames.nextElement(); System.out.println(name + ": " + request.getAttribute(name).toString()); }//from w w w . j av a 2 s . co m } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.siteArchive.streams.FetcherRequestWrapper.java
public FetcherRequestWrapper(HttpServletRequest request) { super(request); this.attributes = new HashMap<String, Object>(); Enumeration names = request.getAttributeNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); this.attributes.put(name, request.getAttribute(name)); }//from www . j a v a2 s . c o m }