java.lang.Object
com.semanticcms.core.servlet.PageContext
HttpServletRequest, HttpServletResponse, and the response PrintWriter are frequently accessed
while also frequently updated by elements for capture. It is tedious to pass these objects around
all over. Also, with the lambda scoping in Java 8, it is easy to use the wrong object from a
different scope (and possibly capturing context).
Each context is intended to be established and used within a single servlet implementation. Do not assume correct management of PageContext between different pages, servlets, or files. If in doubt, skip this shortcut and pass explicit object references around.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacePageContext.PageContextCallableSkipE<V,Ex extends Exception> static interfacestatic interfacestatic interfacestatic interfacestatic interfacePageContext.PageContextRunnableSkipEE<Ex1 extends Throwable,Ex2 extends Throwable> -
Method Summary
Modifier and TypeMethodDescriptionstatic PrintWritergetOut()Gets the current response writer.static HttpServletRequestGets the current request.static HttpServletResponseGets the current response.static ServletContextGets the current servlet context.static <V> VnewPageContext(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallable<V> target) static voidnewPageContext(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnable target) static <V> VnewPageContextSkip(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkip<V> target) Establishes a new page context.static voidnewPageContextSkip(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkip target) Establishes a new page context.static <V,Ex extends Exception>
VnewPageContextSkipE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkipE<V, Ex> target) static <Ex extends Throwable>
voidnewPageContextSkipE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkipE<Ex> target) newPageContextSkipEE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkipEE<V, Ex1, Ex2> target) newPageContextSkipEE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkipEE<Ex1, Ex2> target)
-
Method Details
-
newPageContext
public static void newPageContext(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnable target) throws ServletException, IOException - Throws:
ServletExceptionIOException
-
newPageContext
public static <V> V newPageContext(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallable<V> target) throws ServletException, IOException - Throws:
ServletExceptionIOException
-
newPageContextSkip
public static void newPageContextSkip(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkip target) throws ServletException, IOException, SkipPageException Establishes a new page context. This usually does not need to be done directly as creating a page will establish the starting page context. -
newPageContextSkip
public static <V> V newPageContextSkip(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkip<V> target) throws ServletException, IOException, SkipPageException Establishes a new page context. This usually does not need to be done directly as creating a page will establish the starting page context. -
newPageContextSkipE
public static <Ex extends Throwable> void newPageContextSkipE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkipE<Ex> target) throws Ex, ServletException, IOException, SkipPageException - Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
ExServletExceptionIOExceptionSkipPageException
-
newPageContextSkipE
public static <V,Ex extends Exception> V newPageContextSkipE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkipE<V, Ex> target) throws Ex, ServletException, IOException, SkipPageException- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
ExServletExceptionIOExceptionSkipPageException
-
newPageContextSkipEE
public static <Ex1 extends Throwable,Ex2 extends Throwable> void newPageContextSkipEE(ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextRunnableSkipEE<Ex1, Ex2> target) throws Ex1, Ex2, ServletException, IOException, SkipPageException- Throws:
Ex1Ex2ServletExceptionIOExceptionSkipPageException
-
newPageContextSkipEE
public static <V,Ex1 extends Exception, V newPageContextSkipEEEx2 extends Exception> (ServletContext newServletContext, HttpServletRequest newRequest, HttpServletResponse newResponse, PageContext.PageContextCallableSkipEE<V, Ex1, throws Ex1, Ex2, ServletException, IOException, SkipPageExceptionEx2> target) - Throws:
Ex1Ex2ServletExceptionIOExceptionSkipPageException
-
getServletContext
Gets the current servlet context.- Throws:
IllegalStateException- if no context set
-
getRequest
Gets the current request.- Throws:
IllegalStateException- if no context set
-
getResponse
Gets the current response.- Throws:
IllegalStateException- if no context set
-
getOut
Gets the current response writer.- Throws:
IllegalStateException- if no context setIOException
-
