Package org.zkoss.web.servlet.dsp
Class ServletDspContext
java.lang.Object
org.zkoss.web.servlet.dsp.ServletDspContext
- All Implemented Interfaces:
DspContext,RequestContext
- Direct Known Subclasses:
ExtendletDspContext
A DSP context based on HTTP servlet request and response.
- Author:
- tomyeh
-
Constructor Summary
ConstructorsConstructorDescriptionServletDspContext(jakarta.servlet.ServletContext ctx, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Writer out, org.zkoss.util.resource.Locator locator) Constructor with the specified writer.ServletDspContext(jakarta.servlet.ServletContext ctx, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.zkoss.util.resource.Locator locator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the encoded URL.org.zkoss.util.resource.LocatorReturns the locator for loading resources, such as taglib.getOut()Returns the writer, never null.jakarta.servlet.ServletRequestReturns the request, or null if not available.jakarta.servlet.ServletResponseReturns the response, or null if not available.jakarta.servlet.ServletContextReturns the request, or null if not available.org.zkoss.xel.VariableResolverReturns the variable resolver.voidIncludes the specified URI and render the result to the specified output.booleanReturns whether this page is included.voidsetContentType(String ctype) Sets the content type of the output.voidChanges the writer of this context to the specified one.
-
Constructor Details
-
ServletDspContext
public ServletDspContext(jakarta.servlet.ServletContext ctx, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.zkoss.util.resource.Locator locator) Constructor.- Parameters:
locator- used to locate resources, such as taglib. If null is specified, the locator for the specified servlet context is used. (In other words, we use ServletContextLocator(ctx), if locator is null).
-
ServletDspContext
public ServletDspContext(jakarta.servlet.ServletContext ctx, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Writer out, org.zkoss.util.resource.Locator locator) Constructor with the specified writer.- Parameters:
locator- used to locate resources, such as taglib. If null is specified, the locator for the specified servlet context is used. (In other words, we use ServletContextLocator(ctx), if locator is null).out- the output to generate the result. If null, it is the same asServletDspContext(ServletContext,HttpServletRequest,HttpServletResponse,Locator)In other words, response.getWriter() is used.- Since:
- 2.4.1
-
-
Method Details
-
getLocator
public org.zkoss.util.resource.Locator getLocator()Description copied from interface:DspContextReturns the locator for loading resources, such as taglib. You might return null if the page not referencing external resources.To load the resource from a web application, use
ServletContextLocatorTo load the resource from class path, use org.zkoss.util.resource.Resources.getDefault().- Specified by:
getLocatorin interfaceDspContext
-
setContentType
Description copied from interface:DspContextSets the content type of the output.- Specified by:
setContentTypein interfaceDspContext
-
setOut
Description copied from interface:DspContextChanges the writer of this context to the specified one.- Specified by:
setOutin interfaceDspContext- Parameters:
out- the new writer. If null, it is restored to the default one.
-
encodeURL
Description copied from interface:DspContextReturns the encoded URL. The returned URL is also encoded with HttpServletResponse.encodeURL.- Specified by:
encodeURLin interfaceDspContext- Parameters:
uri- it must be empty or starts with "/". It might contain "*" for current browser code and Locale.- Returns:
- the complete URL (excluding the machine name). It includes the context path and the servlet to interpret this extended resource.
- Throws:
jakarta.servlet.ServletExceptionIOException
-
include
Description copied from interface:DspContextIncludes the specified URI and render the result to the specified output.- Specified by:
includein interfaceDspContext- Parameters:
uri- the URI to include. It is OK to relevant (without leading '/'). If starts with "/", the context path of request is assumed. To reference to foreign context, use "~ctx/" where ctx is the context path of the foreign context (without leading '/').params- a map of parameters, or null to ignore. The map is passed thru the request attribute called arg.- Throws:
jakarta.servlet.ServletExceptionIOException
-
isIncluded
public boolean isIncluded()Description copied from interface:DspContextReturns whether this page is included.- Specified by:
isIncludedin interfaceDspContext
-
getOut
Description copied from interface:RequestContextReturns the writer, never null.- Specified by:
getOutin interfaceRequestContext- Throws:
IOException
-
getRequest
public jakarta.servlet.ServletRequest getRequest()Description copied from interface:RequestContextReturns the request, or null if not available.- Specified by:
getRequestin interfaceRequestContext
-
getResponse
public jakarta.servlet.ServletResponse getResponse()Description copied from interface:RequestContextReturns the response, or null if not available.- Specified by:
getResponsein interfaceRequestContext
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()Description copied from interface:RequestContextReturns the request, or null if not available.- Specified by:
getServletContextin interfaceRequestContext
-
getVariableResolver
public org.zkoss.xel.VariableResolver getVariableResolver()Description copied from interface:RequestContextReturns the variable resolver.- Specified by:
getVariableResolverin interfaceRequestContext
-