Tabnine Logo
HttpServletRequest.getAttribute
Code IndexAdd Tabnine to your IDE (free)

How to use
getAttribute
method
in
javax.servlet.http.HttpServletRequest

Best Java code snippets using javax.servlet.http.HttpServletRequest.getAttribute (Showing top 20 results out of 11,484)

Refine searchRefine arrow

  • HttpServletRequest.setAttribute
  • HttpServletRequest.getRequestURI
  • HttpServletRequest.getParameter
  • HttpServletRequest.getServletPath
  • HttpServletRequest.getPathInfo
  • HttpServletRequest.getContextPath
origin: spring-projects/spring-framework

private static String getRequestUri(HttpServletRequest request) {
  String uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
  if (uri == null) {
    uri = request.getRequestURI();
  }
  return uri;
}
origin: spring-projects/spring-framework

/**
 * 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;
}
origin: spring-projects/spring-framework

/**
 * 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);
}
origin: apache/shiro

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;
}
origin: spring-projects/spring-framework

@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);
}
origin: com.vaadin/vaadin-server

            ? ""
            : ":" + 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();
origin: spring-projects/spring-framework

@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;
}
origin: BroadleafCommerce/BroadleafCommerce

@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));
origin: apache/nifi

  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) {
origin: com.h2database/h2

  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);
origin: spring-projects/spring-framework

@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;
}
origin: jersey/jersey

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());
origin: BroadleafCommerce/BroadleafCommerce

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));
origin: org.apache.cxf/cxf-rt-transports-http

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(),
origin: perwendel/spark

/**
 * 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);
}
origin: javamelody/javamelody

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");
  }
}
origin: BroadleafCommerce/BroadleafCommerce

    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));
origin: BroadleafCommerce/BroadleafCommerce

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(",");
origin: net.sf.matrixjavalib/mxlib-web

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;
}
origin: wildfly/wildfly

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(",");
javax.servlet.httpHttpServletRequestgetAttribute

Popular methods of HttpServletRequest

  • getHeader
    Returns the value of the specified request header as a String. If the request did not include a head
  • getParameter
  • getRequestURI
    Returns the part of this request's URL from the protocol name up to the query string in the first li
  • getSession
    Returns the current HttpSession associated with this request or, if there is no current session and
  • getMethod
    Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT
  • getContextPath
    Returns the portion of the request URI that indicates the context of the request. The context path a
  • getQueryString
    Returns the query string that is contained in the request URL after the path. This method returns nu
  • setAttribute
  • getPathInfo
    Returns any extra path information associated with the URL the client sent when it made this request
  • getRequestURL
    Reconstructs the URL the client used to make the request. The returned URL contains a protocol, serv
  • getRemoteAddr
  • getServletPath
    Returns the part of this request's URL that calls the servlet. This path starts with a "/" character
  • getRemoteAddr,
  • getServletPath,
  • getInputStream,
  • getParameterMap,
  • getCookies,
  • getServerName,
  • getHeaderNames,
  • getScheme,
  • getServerPort

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now