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:com.adito.boot.Util.java
/** * Dump all request attributes to {@link System#err}. * //from w ww . j ava 2s . c om * @param request request to get attributes from */ public static void dumpRequestAttributes(HttpServletRequest request) { System.err.println("Request attributes for " + request.getPathTranslated()); for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) { String n = (String) e.nextElement(); System.err.println(" " + n + " = " + request.getAttribute(n)); } }
From source file:org.mule.transport.servlet.MockHttpServletRequestBuilder.java
private void addAttributeExpectations(HttpServletRequest mockRequest) { Enumeration<String> nameEnum = null; if (attributes != null) { nameEnum = keyEnumeration(attributes); for (Map.Entry<String, String> entry : attributes.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); when(mockRequest.getAttribute(eq(key))).thenReturn(value); }//from www.ja v a2 s . co m } when(mockRequest.getAttributeNames()).thenReturn(nameEnum); }
From source file:org.nuxeo.ecm.platform.ui.web.auth.cleartrust.ClearTrustAuthenticator.java
protected void displayRequestInformation(HttpServletRequest request) { log.debug(">>>>>>>>>>>>> Here is the request: "); for (Enumeration headerNames = request.getHeaderNames(); headerNames.hasMoreElements();) { String headerName = (String) headerNames.nextElement(); log.debug("header " + headerName + " : [" + request.getHeader(headerName) + "]"); }/* w ww .j a v a2 s .c om*/ for (Enumeration attributeNames = request.getAttributeNames(); attributeNames.hasMoreElements();) { String attributeName = (String) attributeNames.nextElement(); log.debug("attribute " + attributeName + " : [" + request.getAttribute(attributeName) + "]"); } for (Enumeration parameterNames = request.getParameterNames(); parameterNames.hasMoreElements();) { String parameterName = (String) parameterNames.nextElement(); log.debug("parameter " + parameterName + " : [" + request.getParameter(parameterName) + "]"); } }
From source file:org.jkcsoft.web.struts.http.controllers.HttpHelper.java
public static void logRequest(HttpServletRequest request, Object logCategory) { // quick reject if (!LogHelper.getLogger(logCategory).isDebugEnabled()) return;/* w ww . ja va 2s .c o m*/ StringBuilder sbMsg = new StringBuilder(100); appendLine(sbMsg, ""); appendLine(sbMsg, "---------- Start Request Dump:"); appendLine(sbMsg, "Query String = " + request.getQueryString()); appendLine(sbMsg, "Path Info " + request.getPathInfo()); appendLine(sbMsg, "getServletPath " + request.getServletPath()); Enumeration e; String name; appendLine(sbMsg, "-------------- Header Information"); e = request.getAttributeNames(); while (e.hasMoreElements()) { name = (String) e.nextElement(); appendLine(sbMsg, name + "=" + request.getAttribute(name).toString()); } e = request.getHeaderNames(); String header; while (e.hasMoreElements()) { header = (String) e.nextElement(); appendLine(sbMsg, header + "=" + request.getHeader(header)); } appendLine(sbMsg, "-------------- Parameter Information"); e = request.getParameterNames(); while (e.hasMoreElements()) { name = (String) e.nextElement(); String[] values = request.getParameterValues(name); String value = ""; for (int inx = 0; inx < values.length; inx++) { value = value + values[inx] + ","; } appendLine(sbMsg, name + "=" + value); } appendLine(sbMsg, "-------------- Attribute Information"); appendLine(sbMsg, "---------- End Request Dump:"); LogHelper.debug(logCategory, sbMsg); }
From source file:org.sonatype.nexus.repository.httpbridge.internal.HttpRequestAdapter.java
public HttpRequestAdapter(final HttpServletRequest httpServletRequest, final String path) { checkNotNull(httpServletRequest);/*from w ww. ja v a2 s . co m*/ this.action = httpServletRequest.getMethod(); this.requestUrl = httpServletRequest.getRequestURL().toString(); this.path = checkNotNull(path); this.parameters = new HttpParametersAdapter(httpServletRequest); this.headers = new HttpHeadersAdapter(httpServletRequest); // copy http-servlet-request attributes Enumeration<String> attributes = httpServletRequest.getAttributeNames(); while (attributes.hasMoreElements()) { String name = attributes.nextElement(); getAttributes().set(name, httpServletRequest.getAttribute(name)); } this.payload = new HttpRequestPayloadAdapter(httpServletRequest); // We're circumventing ServletFileUpload.isMultipartContent as some clients (nuget) use PUT for multipart uploads this.multipart = FileUploadBase.isMultipartContent(new ServletRequestContext(httpServletRequest)); if (multipart) { this.multiPayloads = new HttpPartIteratorAdapter(httpServletRequest); } }
From source file:org.icatproject.idav.methods.AbstractMethod.java
protected void logRequestAttributes(HttpServletRequest request) { Enumeration<String> attrNames = request.getAttributeNames(); LOG.trace("--- HttpServletRequest attribute values ---"); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); String attrValue = request.getAttribute(attrName).toString(); LOG.trace(attrName + " : " + attrValue); }/*w w w. ja v a 2 s . c o m*/ LOG.trace("-------------------------------------------"); }
From source file:com.sinosoft.one.mvc.web.impl.thread.RootEngine.java
/** * Restore the request attributes after an include. * /*from w ww .j av a2s . c o m*/ * before the include */ private void restoreRequestAttributesAfterInclude(Invocation inv) { logger.debug("Restoring snapshot of request attributes after include"); HttpServletRequest request = inv.getRequest(); @SuppressWarnings("unchecked") Map<String, Object> attributesSnapshot = (Map<String, Object>) inv .getAttribute("$$one-mvc.attributesBeforeInclude"); // Need to copy into separate Collection here, to avoid side effects // on the Enumeration when removing attributes. Set<String> attrsToCheck = new HashSet<String>(); Enumeration<?> attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); attrsToCheck.add(attrName); } // Iterate over the attributes to check, restoring the original value // or removing the attribute, respectively, if appropriate. for (String attrName : attrsToCheck) { Object attrValue = attributesSnapshot.get(attrName); if (attrValue != null) { if (logger.isDebugEnabled()) { logger.debug("Restoring original value of attribute [" + attrName + "] after include"); } request.setAttribute(attrName, attrValue); } else { if (logger.isDebugEnabled()) { logger.debug("Removing attribute [" + attrName + "] after include"); } request.removeAttribute(attrName); } } }
From source file:net.paoding.rose.web.impl.thread.RootEngine.java
/** * Restore the request attributes after an include. * //from w w w . j a v a 2 s . c o m * @param request current HTTP request * @param attributesSnapshot the snapshot of the request attributes * before the include */ private void restoreRequestAttributesAfterInclude(Invocation inv) { logger.debug("Restoring snapshot of request attributes after include"); HttpServletRequest request = inv.getRequest(); @SuppressWarnings("unchecked") Map<String, Object> attributesSnapshot = (Map<String, Object>) inv .getAttribute("$$paoding-rose.attributesBeforeInclude"); // Need to copy into separate Collection here, to avoid side effects // on the Enumeration when removing attributes. Set<String> attrsToCheck = new HashSet<String>(); Enumeration<?> attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); attrsToCheck.add(attrName); } // Iterate over the attributes to check, restoring the original value // or removing the attribute, respectively, if appropriate. for (String attrName : attrsToCheck) { Object attrValue = attributesSnapshot.get(attrName); if (attrValue != null) { if (logger.isDebugEnabled()) { logger.debug("Restoring original value of attribute [" + attrName + "] after include"); } request.setAttribute(attrName, attrValue); } else { if (logger.isDebugEnabled()) { logger.debug("Removing attribute [" + attrName + "] after include"); } request.removeAttribute(attrName); } } }
From source file:org.infoglue.deliver.portal.dispatcher.PortalServletDispatcher.java
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException { if (log.isDebugEnabled()) { log.debug("\n******************************************** infogluePortal service()"); Enumeration enumeration = req.getParameterNames(); while (enumeration.hasMoreElements()) { String name = (String) enumeration.nextElement(); Object o = req.getParameter(name); log.debug(name + "=" + o); }/*from w w w . j a v a 2s .c o m*/ enumeration = req.getAttributeNames(); while (enumeration.hasMoreElements()) { String name = (String) enumeration.nextElement(); Object o = req.getAttribute(name); log.debug(name + "=" + o); } } // TODO not very nice, or?. Necessary to call before portlet execution. PortletContainerServices.prepare(uniqueContainerName); // Necessary to allow deliver parts to update portlet container when a new // portlet is uploaded. req.setAttribute(PORTLET_CONTAINER_NAME, uniqueContainerName); // Delegate to super-servlet (infoglue) super.service(req, resp); }
From source file:com.laxser.blitz.web.impl.thread.RootEngine.java
/** * Restore the request attributes after an include. * /*from w w w. j av a 2 s . com*/ * @param request current HTTP request * @param attributesSnapshot the snapshot of the request attributes * before the include */ private void restoreRequestAttributesAfterInclude(Invocation inv) { logger.debug("Restoring snapshot of request attributes after include"); HttpServletRequest request = inv.getRequest(); @SuppressWarnings("unchecked") Map<String, Object> attributesSnapshot = (Map<String, Object>) inv .getAttribute("$$paoding-blitz.attributesBeforeInclude"); // Need to copy into separate Collection here, to avoid side effects // on the Enumeration when removing attributes. Set<String> attrsToCheck = new HashSet<String>(); Enumeration<?> attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); attrsToCheck.add(attrName); } // Iterate over the attributes to check, restoring the original value // or removing the attribute, respectively, if appropriate. for (String attrName : attrsToCheck) { Object attrValue = attributesSnapshot.get(attrName); if (attrValue != null) { if (logger.isDebugEnabled()) { logger.debug("Restoring original value of attribute [" + attrName + "] after include"); } request.setAttribute(attrName, attrValue); } else { if (logger.isDebugEnabled()) { logger.debug("Removing attribute [" + attrName + "] after include"); } request.removeAttribute(attrName); } } }