- java.lang.Object
-
- com.aoapps.servlet.http.Dispatcher
-
public class Dispatcher extends Object
Static utilities that may be useful by servlet/JSP/taglib environments.- Author:
- AO Industries, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description static StringARG_REQUEST_ATTRIBUTEThe name of the request-scope Map that will contain the arguments for the current page.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidforward(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response)static voidforward(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response, Map<String,?> args)Performs a forward with the provided servlet path and associated dispatcher.static voidforward(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response)static voidforward(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response, Map<String,?> args)Performs a forward, allowing page-relative paths and setting all values compatible with <ao:forward> tag.static StringgetCurrentPagePath(HttpServletRequest request)Gets the current page path, including any effects from include/forward.static StringgetDispatchedPage(ServletRequest request)Gets the current request dispatched page or null if not set.static StringgetOriginalPage(ServletRequest request)Gets the current request original page or null if not set.static StringgetOriginalPagePath(HttpServletRequest request)Gets the original page path corresponding to the original request before any forward/include.static voidinclude(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response)static voidinclude(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response, Map<String,?> args)Performs a forward with the provided servlet path and associated dispatcher.static voidinclude(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response)static voidinclude(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response, Map<String,?> args)Performs an include, allowing page-relative paths and setting all values compatible with <ao:include> tag.static voidsetDispatchedPage(ServletRequest request, String dispatchedPage)Sets the current request dispatched page.static voidsetOriginalPage(ServletRequest request, String page)Sets the current request original page.
-
-
-
Field Detail
-
ARG_REQUEST_ATTRIBUTE
public static final String ARG_REQUEST_ATTRIBUTE
The name of the request-scope Map that will contain the arguments for the current page.- See Also:
- Constant Field Values
-
-
Method Detail
-
getOriginalPage
public static String getOriginalPage(ServletRequest request)
Gets the current request original page or null if not set.
-
setOriginalPage
public static void setOriginalPage(ServletRequest request, String page)
Sets the current request original page.
-
getOriginalPagePath
public static String getOriginalPagePath(HttpServletRequest request)
Gets the original page path corresponding to the original request before any forward/include. If no original page available, uses the servlet path from the provided request.
-
getDispatchedPage
public static String getDispatchedPage(ServletRequest request)
Gets the current request dispatched page or null if not set.
-
setDispatchedPage
public static void setDispatchedPage(ServletRequest request, String dispatchedPage)
Sets the current request dispatched page.
-
getCurrentPagePath
public static String getCurrentPagePath(HttpServletRequest request)
Gets the current page path, including any effects from include/forward. This will be the path of the current page on forward or include. This may be used as a substitute for HttpServletRequest.getServletPath() when the current page is needed instead of the originally requested servlet.
-
forward
public static void forward(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response, Map<String,?> args) throws ServletException, IOException
Performs a forward with the provided servlet path and associated dispatcher.- Parameters:
args- The arguments for the page, make unmodifiable and accessible as request-scope var "arg"- Throws:
ServletExceptionIOException
-
forward
public static void forward(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-
forward
public static void forward(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response, Map<String,?> args) throws ServletException, IOException
Performs a forward, allowing page-relative paths and setting all values compatible with <ao:forward> tag.- Parameters:
args- The arguments for the page, make unmodifiable and accessible as request-scope var "arg"- Throws:
ServletExceptionIOException- See Also:
forward(java.lang.String, javax.servlet.RequestDispatcher, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Map)
-
forward
public static void forward(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-
include
public static void include(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response, Map<String,?> args) throws SkipPageException, ServletException, IOException
Performs a forward with the provided servlet path and associated dispatcher.- Parameters:
args- The arguments for the page, make unmodifiable and accessible as request-scope var "arg"- Throws:
SkipPageException- when the included page has been skipped due to a redirect.ServletExceptionIOException
-
include
public static void include(String contextRelativePath, RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response) throws SkipPageException, ServletException, IOException
-
include
public static void include(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response, Map<String,?> args) throws SkipPageException, ServletException, IOException
Performs an include, allowing page-relative paths and setting all values compatible with <ao:include> tag.- Parameters:
args- The arguments for the page, make unmodifiable and accessible as request-scope var "arg"- Throws:
SkipPageException- when the included page has been skipped due to a redirect.ServletExceptionIOException- See Also:
include(java.lang.String, javax.servlet.RequestDispatcher, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Map)
-
include
public static void include(ServletContext servletContext, String page, HttpServletRequest request, HttpServletResponse response) throws SkipPageException, ServletException, IOException
-
-