private static String getRequestUri(HttpServletRequest request) { String uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); if (uri == null) { uri = request.getRequestURI(); } return uri; }
/** * Return the servlet path for the given request, detecting an include request * URL if called within a RequestDispatcher include. * @param request current HTTP request * @return the servlet path */ public String getOriginatingServletPath(HttpServletRequest request) { String servletPath = (String) request.getAttribute(WebUtils.FORWARD_SERVLET_PATH_ATTRIBUTE); if (servletPath == null) { servletPath = request.getServletPath(); } return servletPath; }
/** * Return the context path for the given request, detecting an include request * URL if called within a RequestDispatcher include. * <p>As the value returned by {@code request.getContextPath()} is <i>not</i> * decoded by the servlet container, this method will decode it. * @param request current HTTP request * @return the context path */ public String getOriginatingContextPath(HttpServletRequest request) { String contextPath = (String) request.getAttribute(WebUtils.FORWARD_CONTEXT_PATH_ATTRIBUTE); if (contextPath == null) { contextPath = request.getContextPath(); } return decodeRequestString(request, contextPath); }
private HttpServletRequest createMockRequest(String path) { HttpServletRequest request = createNiceMock(HttpServletRequest.class); expect(request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)).andReturn(null).anyTimes(); expect(request.getContextPath()).andReturn(""); expect(request.getRequestURI()).andReturn(path); replay(request); return request; }
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { HttpServletRequest requestToUse = request; if ("POST".equals(request.getMethod()) && request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) == null) { String paramValue = request.getParameter(this.methodParam); if (StringUtils.hasLength(paramValue)) { String method = paramValue.toUpperCase(Locale.ENGLISH); if (ALLOWED_METHODS.contains(method)) { requestToUse = new HttpMethodRequestWrapper(request, method); } } } filterChain.doFilter(requestToUse, response); }
? "" : ":" + request.getServerPort()) + request.getRequestURI()); String servletPath = ""; if (request .getAttribute("javax.servlet.include.servlet_path") != null) { .getAttribute("javax.servlet.include.context_path") .toString() + request .getAttribute("javax.servlet.include.servlet_path"); servletPath = request.getContextPath() + request.getServletPath();
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { if (request.getAttribute("test2") != null) { throw new ServletException("Wrong interceptor order"); } request.setAttribute("test1", "test1"); request.setAttribute("test1x", "test1x"); request.setAttribute("test1y", "test1y"); return true; }
@Override protected void doFilterInternalUnlessIgnored(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (!shouldProcessURL(request, request.getRequestURI())) { if (LOG.isTraceEnabled()) { LOG.trace(String.format("%s not processing URL %s", getClass().getName(), request.getRequestURI())); String requestURIWithoutContext; if (request.getContextPath() != null) { requestURIWithoutContext = request.getRequestURI().substring(request.getContextPath().length()); } else { requestURIWithoutContext = request.getRequestURI(); if (request.getAttribute(REQUEST_DTO_PARAM_NAME) == null) { request.setAttribute(REQUEST_DTO_PARAM_NAME, new RequestDTOImpl(request));
putAttribute(attributes, HTTPUtils.HTTP_CONTEXT_ID, contextIdentifier); putAttribute(attributes, "mime.type", request.getContentType()); putAttribute(attributes, "http.servlet.path", request.getServletPath()); putAttribute(attributes, "http.context.path", request.getContextPath()); putAttribute(attributes, "http.method", request.getMethod()); putAttribute(attributes, "http.local.addr", request.getLocalAddr()); putAttribute(attributes, "http.remote.user", request.getRemoteUser()); putAttribute(attributes, "http.protocol", request.getProtocol()); putAttribute(attributes, HTTPUtils.HTTP_REQUEST_URI, request.getRequestURI()); putAttribute(attributes, "http.request.url", request.getRequestURL().toString()); putAttribute(attributes, "http.auth.type", request.getAuthType()); while (paramEnumeration.hasMoreElements()) { final String paramName = paramEnumeration.nextElement(); final String value = request.getParameter(paramName); attributes.put("http.param." + paramName, value); final X509Certificate certs[] = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); final String subjectDn; if (certs != null && certs.length > 0) {
throws IOException { req.setCharacterEncoding("utf-8"); String file = req.getPathInfo(); if (file == null) { resp.sendRedirect(req.getRequestURI() + "/"); return; } else if (file.startsWith("/")) { while (en.hasMoreElements()) { String name = en.nextElement().toString(); String value = req.getAttribute(name).toString(); attributes.put(name, value); while (en.hasMoreElements()) { String name = en.nextElement().toString(); String value = req.getParameter(name); attributes.put(name, value);
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { if (request.getAttribute("test1x") == null) { throw new ServletException("Wrong interceptor order"); } if (request.getParameter("abort") != null) { return false; } request.setAttribute("test2", "test2"); request.setAttribute("test2x", "test2x"); request.setAttribute("test2y", "test2y"); return true; }
if (request.getAttribute("javax.servlet.include.request_uri") != null) { final String includeRequestURI = (String) request.getAttribute("javax.servlet.include.request_uri"); if (!includeRequestURI.equals(request.getRequestURI())) { doFilter(request, response, chain, includeRequestURI, (String) request.getAttribute("javax.servlet.include.servlet_path"), (String) request.getAttribute("javax.servlet.include.query_string")); return; final String servletPath = request.getServletPath() + (request.getPathInfo() == null ? "" : request.getPathInfo()); request.getRequestURI(), servletPath, request.getQueryString());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) { String notification = (String) request.getAttribute(STATECHANGENOTIFICATIONTOKEN); if (Boolean.valueOf(notification)) { String uri = request.getRequestURI(); Enumeration<String> params = request.getParameterNames(); StringBuilder sb = new StringBuilder(); sb.append(request.getParameter(param));
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Object obj = request.getAttribute(ServletController.AUTH_SERVICE_LIST); boolean isAuthServiceList = false; if (obj != null) { String authServiceListRealm = (String)request.getAttribute(ServletController.AUTH_SERVICE_LIST_REALM); ServiceListJAASAuthenticator authenticator = new ServiceListJAASAuthenticator(); authenticator.setRealm(authServiceListRealm); if (request.getParameter("stylesheet") != null) { renderStyleSheet(request, response); return; String servletPath = request.getServletPath(); if (servletPath != null) { styleSheetPath += servletPath; String pathInfo = request.getPathInfo(); if (pathInfo != null) { styleSheetPath += pathInfo; Object basePath = request.getAttribute(Message.BASE_PATH); serviceListWriter.writeServiceList(response.getWriter(), basePath == null ? null : basePath.toString(),
/** * Gets a resource from a servlet request * * @param request the servlet request * @return the resource or null if not found * @throws java.net.MalformedURLException thrown when malformed URL. */ public AbstractFileResolvingResource getResource(HttpServletRequest request) throws MalformedURLException { String servletPath; String pathInfo; boolean included = request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null; if (included) { servletPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); if (servletPath == null && pathInfo == null) { servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } } else { servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } String pathInContext = addPaths(servletPath, pathInfo); return getResource(pathInContext); }
void addCookie(HttpServletRequest req, HttpServletResponse resp, String cookieName, String cookieValue) { if (!"added".equals(req.getAttribute(cookieName))) { final Cookie cookie = new Cookie(cookieName, cookieValue); // cookie persistant, valide pendant 30 jours cookie.setMaxAge(30 * 24 * 60 * 60); // inutile d'envoyer ce cookie aux autres URLs que le monitoring cookie.setPath(req.getRequestURI()); resp.addCookie(cookie); req.setAttribute(cookieName, "added"); } }
searchCriteria.setPageSize(Math.min(requestedPageSize, maxPageSize)); } else if (Objects.equals(key, SearchCriteria.QUERY_STRING)) { String query = request.getParameter(SearchCriteria.QUERY_STRING); try { if (StringUtils.isNotEmpty(query)) { searchCriteria.setCategory((Category) request.getAttribute(CategoryHandlerMapping.CURRENT_CATEGORY_ATTRIBUTE_NAME));
while(enAttr.hasMoreElements()){ String attributeName = (String)enAttr.nextElement(); if (request.getAttribute(attributeName) instanceof String) { builder.append("\""); builder.append(attributeName); builder.append(":"); builder.append("\""); builder.append(request.getAttribute(attributeName).toString()); builder.append("\""); builder.append(","); builder.append(":"); builder.append("\""); builder.append(request.getParameter(paramName)); builder.append("\""); builder.append(",");
private static String getUrl(final HttpServletRequest request) { String url = request.getParameter(URL_KEY); if (StringUtils.isEmpty(url)) { url = (String) request.getAttribute(URL_KEY); } if (StringUtils.isEmpty(url)) { url = request.getServletPath(); } request.setAttribute(URL_KEY, url); return url; }
sb.append("[").append(httpRequest.getContextPath()); sb.append(":cookies=").append(Arrays.toString(httpRequest.getCookies())).append(":headers="); String attrName = (String) enu.nextElement(); sb.append(attrName).append("="); sb.append(httpRequest.getAttribute(attrName)).append(",");