jodd.servlet
Class DispatcherUtil

java.lang.Object
  extended by jodd.servlet.DispatcherUtil

public class DispatcherUtil
extends java.lang.Object

Request utilities for path, uri, query strings etc..


Field Summary
static java.lang.String FORWARD_CONTEXT_PATH
           
static java.lang.String FORWARD_PATH_INFO
           
static java.lang.String FORWARD_QUERY_STRING
           
static java.lang.String FORWARD_REQUEST_URI
           
static java.lang.String FORWARD_SERVLET_PATH
           
static java.lang.String INCLUDE_CONTEXT_PATH
           
static java.lang.String INCLUDE_PATH_INFO
           
static java.lang.String INCLUDE_QUERY_STRING
           
static java.lang.String INCLUDE_REQUEST_URI
           
static java.lang.String INCLUDE_SERVLET_PATH
           
 
Constructor Summary
DispatcherUtil()
           
 
Method Summary
static boolean forward(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String page)
          Forward to page which path is relative to the current HTTP request.
static boolean forwardAbsolute(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletResponse response, java.lang.String page)
          Forward to page path relative to the root of the ServletContext.
static boolean forwardAbsolute(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String resource)
          Forward to page path relative to the root of the ServletContext.
static boolean forwardNamed(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletResponse response, java.lang.String resource)
          Forward to named resource.
static boolean forwardNamed(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String resource)
          Forward to named resource.
static java.lang.String getActionPath(javax.servlet.http.HttpServletRequest request)
          Returns full action path: uri + query string.
static java.lang.String getBaseContextPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getBasePathInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getBaseQueryString(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getBaseRequestUri(javax.servlet.http.HttpServletRequest request)
          Returns the base (top-level) uri.
static java.lang.String getBaseServletPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getContextPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getForwardContextPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getForwardPathInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getForwardQueryString(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getForwardRequestUri(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getForwardServletPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getIncludeContextPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getIncludePathInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getIncludeQueryString(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getIncludeRequestUri(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getIncludeServletPath(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getPathInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getQueryString(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getRequestUri(javax.servlet.http.HttpServletRequest request)
          Get current request uri.
static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)
           
static boolean include(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String page)
          Include page which path is relative to the current HTTP request.
static boolean includeAbsolute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page)
          Include page which path relative to the root of the ServletContext.
static boolean includeAbsolute(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page)
          Include page which path relative to the root of the ServletContext.
static boolean includeNamed(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletResponse response, java.lang.String resource)
          Include named resource.
static boolean includeNamed(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String page)
          Include named resource.
static boolean isPageIncluded(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Returns true if current page is included.
static boolean isTopLevelRequest(javax.servlet.http.HttpServletRequest request)
          Returns true if request is a top-level one, i.e. previously not included or forwarded.
static java.lang.String makeActionPath(java.lang.String uri, java.lang.String query)
          Builds action path from uri and query.
static void redirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String url)
          Performs redirection to specified page.
static CharArrayResponseWrapper wrap(javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page)
           
static CharArrayResponseWrapper wrapAbsolute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page)
           
static CharArrayResponseWrapper wrapAbsolute(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page)
           
static CharArrayResponseWrapper wrapNamed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String resource)
           
static CharArrayResponseWrapper wrapNamed(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String resource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE_REQUEST_URI

public static final java.lang.String INCLUDE_REQUEST_URI
See Also:
Constant Field Values

INCLUDE_CONTEXT_PATH

public static final java.lang.String INCLUDE_CONTEXT_PATH
See Also:
Constant Field Values

INCLUDE_SERVLET_PATH

public static final java.lang.String INCLUDE_SERVLET_PATH
See Also:
Constant Field Values

INCLUDE_PATH_INFO

public static final java.lang.String INCLUDE_PATH_INFO
See Also:
Constant Field Values

INCLUDE_QUERY_STRING

public static final java.lang.String INCLUDE_QUERY_STRING
See Also:
Constant Field Values

FORWARD_REQUEST_URI

public static final java.lang.String FORWARD_REQUEST_URI
See Also:
Constant Field Values

FORWARD_CONTEXT_PATH

public static final java.lang.String FORWARD_CONTEXT_PATH
See Also:
Constant Field Values

FORWARD_SERVLET_PATH

public static final java.lang.String FORWARD_SERVLET_PATH
See Also:
Constant Field Values

FORWARD_PATH_INFO

public static final java.lang.String FORWARD_PATH_INFO
See Also:
Constant Field Values

FORWARD_QUERY_STRING

public static final java.lang.String FORWARD_QUERY_STRING
See Also:
Constant Field Values
Constructor Detail

DispatcherUtil

public DispatcherUtil()
Method Detail

include

public static boolean include(javax.servlet.ServletRequest request,
                              javax.servlet.ServletResponse response,
                              java.lang.String page)
                       throws java.io.IOException,
                              javax.servlet.ServletException
Include page which path is relative to the current HTTP request.

Throws:
java.io.IOException
javax.servlet.ServletException

includeNamed

public static boolean includeNamed(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.ServletResponse response,
                                   java.lang.String resource)
                            throws java.io.IOException,
                                   javax.servlet.ServletException
Include named resource.

Throws:
java.io.IOException
javax.servlet.ServletException

includeNamed

public static boolean includeNamed(javax.servlet.ServletContext context,
                                   javax.servlet.ServletRequest request,
                                   javax.servlet.ServletResponse response,
                                   java.lang.String page)
                            throws java.io.IOException,
                                   javax.servlet.ServletException
Include named resource.

Throws:
java.io.IOException
javax.servlet.ServletException

includeAbsolute

public static boolean includeAbsolute(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String page)
                               throws java.io.IOException,
                                      javax.servlet.ServletException
Include page which path relative to the root of the ServletContext.

Throws:
java.io.IOException
javax.servlet.ServletException

includeAbsolute

public static boolean includeAbsolute(javax.servlet.ServletContext context,
                                      javax.servlet.ServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String page)
                               throws java.io.IOException,
                                      javax.servlet.ServletException
Include page which path relative to the root of the ServletContext.

Throws:
java.io.IOException
javax.servlet.ServletException

wrap

public static CharArrayResponseWrapper wrap(javax.servlet.ServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            java.lang.String page)
                                     throws java.io.IOException,
                                            javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

wrapNamed

public static CharArrayResponseWrapper wrapNamed(javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response,
                                                 java.lang.String resource)
                                          throws java.io.IOException,
                                                 javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

wrapNamed

public static CharArrayResponseWrapper wrapNamed(javax.servlet.ServletContext context,
                                                 javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response,
                                                 java.lang.String resource)
                                          throws java.io.IOException,
                                                 javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

wrapAbsolute

public static CharArrayResponseWrapper wrapAbsolute(javax.servlet.http.HttpServletRequest request,
                                                    javax.servlet.http.HttpServletResponse response,
                                                    java.lang.String page)
                                             throws java.io.IOException,
                                                    javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

wrapAbsolute

public static CharArrayResponseWrapper wrapAbsolute(javax.servlet.ServletContext context,
                                                    javax.servlet.ServletRequest request,
                                                    javax.servlet.http.HttpServletResponse response,
                                                    java.lang.String page)
                                             throws java.io.IOException,
                                                    javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

forward

public static boolean forward(javax.servlet.ServletRequest request,
                              javax.servlet.ServletResponse response,
                              java.lang.String page)
                       throws java.io.IOException,
                              javax.servlet.ServletException
Forward to page which path is relative to the current HTTP request.

Throws:
java.io.IOException
javax.servlet.ServletException

forwardNamed

public static boolean forwardNamed(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.ServletResponse response,
                                   java.lang.String resource)
                            throws java.io.IOException,
                                   javax.servlet.ServletException
Forward to named resource.

Throws:
java.io.IOException
javax.servlet.ServletException

forwardNamed

public static boolean forwardNamed(javax.servlet.ServletContext context,
                                   javax.servlet.ServletRequest request,
                                   javax.servlet.ServletResponse response,
                                   java.lang.String resource)
                            throws java.io.IOException,
                                   javax.servlet.ServletException
Forward to named resource.

Throws:
java.io.IOException
javax.servlet.ServletException

forwardAbsolute

public static boolean forwardAbsolute(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.ServletResponse response,
                                      java.lang.String page)
                               throws java.io.IOException,
                                      javax.servlet.ServletException
Forward to page path relative to the root of the ServletContext.

Throws:
java.io.IOException
javax.servlet.ServletException

forwardAbsolute

public static boolean forwardAbsolute(javax.servlet.ServletContext context,
                                      javax.servlet.ServletRequest request,
                                      javax.servlet.ServletResponse response,
                                      java.lang.String resource)
                               throws java.io.IOException,
                                      javax.servlet.ServletException
Forward to page path relative to the root of the ServletContext.

Throws:
java.io.IOException
javax.servlet.ServletException

redirect

public static void redirect(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            java.lang.String url)
                     throws java.io.IOException
Performs redirection to specified page.

Throws:
java.io.IOException

getActionPath

public static java.lang.String getActionPath(javax.servlet.http.HttpServletRequest request)
Returns full action path: uri + query string.


makeActionPath

public static java.lang.String makeActionPath(java.lang.String uri,
                                              java.lang.String query)
Builds action path from uri and query.


getIncludeRequestUri

public static java.lang.String getIncludeRequestUri(javax.servlet.http.HttpServletRequest request)

getIncludeContextPath

public static java.lang.String getIncludeContextPath(javax.servlet.http.HttpServletRequest request)

getIncludeServletPath

public static java.lang.String getIncludeServletPath(javax.servlet.http.HttpServletRequest request)

getIncludePathInfo

public static java.lang.String getIncludePathInfo(javax.servlet.http.HttpServletRequest request)

getIncludeQueryString

public static java.lang.String getIncludeQueryString(javax.servlet.http.HttpServletRequest request)

getForwardRequestUri

public static java.lang.String getForwardRequestUri(javax.servlet.http.HttpServletRequest request)

getForwardContextPath

public static java.lang.String getForwardContextPath(javax.servlet.http.HttpServletRequest request)

getForwardServletPath

public static java.lang.String getForwardServletPath(javax.servlet.http.HttpServletRequest request)

getForwardPathInfo

public static java.lang.String getForwardPathInfo(javax.servlet.http.HttpServletRequest request)

getForwardQueryString

public static java.lang.String getForwardQueryString(javax.servlet.http.HttpServletRequest request)

isPageIncluded

public static boolean isPageIncluded(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
Returns true if current page is included.


isTopLevelRequest

public static boolean isTopLevelRequest(javax.servlet.http.HttpServletRequest request)
Returns true if request is a top-level one, i.e. previously not included or forwarded.


getBaseRequestUri

public static java.lang.String getBaseRequestUri(javax.servlet.http.HttpServletRequest request)
Returns the base (top-level) uri.


getRequestUri

public static java.lang.String getRequestUri(javax.servlet.http.HttpServletRequest request)
Get current request uri.


getBaseContextPath

public static java.lang.String getBaseContextPath(javax.servlet.http.HttpServletRequest request)

getContextPath

public static java.lang.String getContextPath(javax.servlet.http.HttpServletRequest request)

getBaseServletPath

public static java.lang.String getBaseServletPath(javax.servlet.http.HttpServletRequest request)

getServletPath

public static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)

getBasePathInfo

public static java.lang.String getBasePathInfo(javax.servlet.http.HttpServletRequest request)

getPathInfo

public static java.lang.String getPathInfo(javax.servlet.http.HttpServletRequest request)

getBaseQueryString

public static java.lang.String getBaseQueryString(javax.servlet.http.HttpServletRequest request)

getQueryString

public static java.lang.String getQueryString(javax.servlet.http.HttpServletRequest request)


Copyright ©2008 Jodd Team