public class RequestUtils extends Object
HttpServletRequest
.
This utility does care both situations: whether or not the current request was dispatched.
So, with this utility, you don't have to read servlet request attributes manually.
Note: Please see the Java Servlet Specification for the detail on the related request attributes.
Modifier and Type | Method and Description |
---|---|
static String |
getContextPath(javax.servlet.http.HttpServletRequest request)
Finds and returns the servlet context path in the following order.
|
static String |
getPathInfo(javax.servlet.http.HttpServletRequest request)
Finds and returns the request URI in the following order.
|
static String |
getRequestURI(javax.servlet.http.HttpServletRequest request)
Finds and returns the request URI in the following order.
|
static String |
getServletPath(javax.servlet.http.HttpServletRequest request)
Finds and returns the request URI in the following order.
|
static boolean |
isDispatched(RequestContext requestContext)
Returns true if the current request was dispatched by either
RequestDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
or RequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse) . |
public static String getContextPath(javax.servlet.http.HttpServletRequest request)
javax.servlet.include.context_path
request attribute if found.javax.servlet.forward.context_path
request attribute if found.request
- public static String getRequestURI(javax.servlet.http.HttpServletRequest request)
javax.servlet.include.request_uri
request attribute if found.javax.servlet.forward.request_uri
request attribute if found.request
- public static String getServletPath(javax.servlet.http.HttpServletRequest request)
javax.servlet.include.servlet_path
request attribute if found.javax.servlet.forward.servlet_path
request attribute if found.request
- public static String getPathInfo(javax.servlet.http.HttpServletRequest request)
javax.servlet.include.path_info
request attribute if found.javax.servlet.forward.path_info
request attribute if found.request
- public static boolean isDispatched(RequestContext requestContext)
RequestDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
or RequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
.
Otherwise, it should return false.requestContext
- Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.