Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.ui
Class ServletRenderingContext

java.lang.Object
  |
  +--oracle.cabo.ui.LogicalNodeRenderingContext
        |
        +--oracle.cabo.ui.RenderedNodeRenderingContext
              |
              +--oracle.cabo.ui.RootRenderingContext
                    |
                    +--oracle.cabo.ui.ServletRenderingContext
All Implemented Interfaces:
java.lang.Cloneable, ImageContext, RenderingContext, StyleContext
Direct Known Subclasses:
BajaRenderingContext

public class ServletRenderingContext
extends RootRenderingContext

An implementation of RenderingContext for Servlets and JSPs.

Creating, configuring, and disposing of ServletRenderingContexts

The ServletRenderingContext class offers a large number of constructors, but all but two have been deprecated! Developers who have access to a JSP PageContext should use the single-argument constructor. Others should use the three-argument constructor that takes a ServletRequest, a ServletResponse, and a ServletConfig. If you're not using a servlet at all, you should be using RootRenderingContext.

Once a ServletRenderingContext has been created, clients can then configure it using any of several setter methods. There's a number of objects you can configure; for a complete list, look at the Javadoc for this class and RootRenderingContext:

  1. The Configuration.
  2. The facet: facets let you specify which "variation-on-a-theme" you want for the current look-and-feel.
  3. The LocaleContext: Control the Locale used for rendering, aas well as locale-related properties like date formatting.
  4. The ErrorLog: overrides how UIX will report errors.
  5. The URLEncoder: overrides how UIX might encode URLs (to encode session information, for example).

Once you've configured your ServletRenderingContext - and only after it's been configured - you need to prepare it for output. (Some of the configuration steps affect the output, so this order is important!) Use the prepareResponse() method to get UIX ready for output. This method can (optionally) set the HTTP "Content-Type" header for you. It's strongly recommended that you leave this header to UIX, and do not try to set it yourself. You may only be using HTML today, but UIX may choose to use something else - XHTML or XML, for example - depending on the agent.

Once you've completed rendering, you need to let the ServletRenderingContext know that it can commit all of its output. Use the finishResponse() method. (But only call this method if you used prepareResponse()!)

ServletRenderingContext properties

ServletRenderingContext registers a number of properties on itself; all of these properties are in the UIConstants.MARLIN_NAMESPACE namespace. All of these properties are, however, best retrieved with each of several static methods on this class, such as getServletResponse(), etc.

ServletRenderingContext also provides access to a number of JSP and Servlet objects. When using the constructors that take JSP or servlet objects, these will be initialized automatically, but clients can set them manually if needed. Clients that use these constructors will also get their error log configured to output to the servlet log.

Additionally, the ServletRenderingContext automatically provides a support for UIX Images and UIX Styles. Clients can configure the locations used by these systems by setting a Configuration object on the context.


Field Summary
static java.lang.String HTTP_SESSION_PROPERTY
          TYPE: HttpSession
static java.lang.String JSP_PAGE_CONTEXT_PROPERTY
          TYPE: PageContext
static java.lang.String JSP_PAGE_PROPERTY
          TYPE: Object
static java.lang.String SERVLET_CONFIG_PROPERTY
          TYPE: ServletConfig
static java.lang.String SERVLET_CONTEXT_PROPERTY
          TYPE: ServletContext
static java.lang.String SERVLET_REQUEST_PROPERTY
          TYPE: ServletRequest
static java.lang.String SERVLET_RESPONSE_PROPERTY
          TYPE: ServletResponse
 
Fields inherited from interface oracle.cabo.ui.RenderingContext
CONTEXT_PATH_PROPERTY, CONTEXT_URI_PROPERTY, SHARED_CONTEXT_PATH_PROPERTY, SHARED_CONTEXT_URI_PROPERTY
 
Constructor Summary
  ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext)
          Creates a rendering context off a JSP PageContext.
  ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext, RendererManager manager)
          Deprecated. Let the RendererManager default.
  ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext, java.lang.String mimeType)
          Deprecated. Let the mime type default.
  ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext, java.lang.String mimeType, RendererManager manager)
          Deprecated. Let the mime type and RendererManager both default.
  ServletRenderingContext(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.ServletConfig config)
          Creates a rendering context for a Servlet request.
  ServletRenderingContext(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.ServletConfig config, java.io.PrintWriter out, java.lang.String mimeType, Agent agent, LocaleContext localeContext, RendererManager manager)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.
protected ServletRenderingContext(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.ServletConfig config, java.io.PrintWriter out, java.lang.String mimeType, Agent agent, LocaleContext localeContext, RendererManager manager, ErrorLog errorLog, URLEncoder urlEncoder)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.
  ServletRenderingContext(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.ServletConfig config, java.io.PrintWriter out, java.lang.String mimeType, RendererManager manager)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.
  ServletRenderingContext(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.io.PrintWriter out)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse()
  ServletRenderingContext(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.io.PrintWriter out, RendererManager manager)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager default
  ServletRenderingContext(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.io.PrintWriter out, java.lang.String mimeType)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the mime type default.
  ServletRenderingContext(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.io.PrintWriter out, java.lang.String mimeType, RendererManager manager)
          Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.
 
Method Summary
protected  ErrorLog createErrorLog()
          Responsible for creating an error log for the rendering context.
protected  OutputMethod createOutputMethod()
          Responsible for creating an output method.
 void finishResponse()
          Finishes a response by closing any writers opened by this rendering context.
protected  Agent getBaseAgent()
          Returns the "base agent", which has not yet been affected by the choice of a rendering facet.
protected  java.util.Locale getDefaultLocale()
          Returns the locale that will be used if no locale could be identified from the request.
 javax.servlet.http.HttpSession getHttpSession()
          Gets the HttpSession context property.
static javax.servlet.http.HttpSession getHttpSession(RenderingContext context)
          Gets the HttpSession context property.
 java.lang.Object getJspPage()
          Gets the JSP page context property.
static java.lang.Object getJspPage(RenderingContext context)
          Gets the JSP page context property.
 javax.servlet.jsp.PageContext getJspPageContext()
          Gets the JSP PageContext context property.
static javax.servlet.jsp.PageContext getJspPageContext(RenderingContext context)
          Gets the JSP PageContext context property.
 LocaleContext getLocaleContext()
          Returns the LocaleContext that should be used for rendering.
 java.lang.Object getProperty(java.lang.String namespace, java.lang.Object key)
          Override of RootRenderingContext.getProperty().
 javax.servlet.ServletConfig getServletConfig()
          Gets the servlet config context property.
static javax.servlet.ServletConfig getServletConfig(RenderingContext context)
          Gets the servlet config context property.
 javax.servlet.ServletContext getServletContext()
          Gets the ServletContext context property.
static javax.servlet.ServletContext getServletContext(RenderingContext context)
          Gets the ServletContext context property.
 javax.servlet.ServletRequest getServletRequest()
          Gets the servlet request context property.
static javax.servlet.ServletRequest getServletRequest(RenderingContext context)
          Gets the servlet request context property.
 javax.servlet.ServletResponse getServletResponse()
          Gets the servlet request context property.
static javax.servlet.ServletResponse getServletResponse(RenderingContext context)
          Gets the servlet request context property.
 void prepareResponse(java.lang.String encoding, boolean setHeaders)
          Prepares the response for a page.
 void setHttpSession(javax.servlet.http.HttpSession session)
          Sets the HttpSession context property.
static void setHttpSession(RenderingContext context, javax.servlet.http.HttpSession session)
          Sets the HttpSession context property.
 void setJspPage(java.lang.Object page)
          Sets the JSP page context property.
static void setJspPage(RenderingContext context, java.lang.Object page)
          Sets the JSP page context property.
 void setJspPageContext(javax.servlet.jsp.PageContext pageContext)
          Sets the JSP PageContext context property.
static void setJspPageContext(RenderingContext context, javax.servlet.jsp.PageContext pageContext)
          Sets the JSP PageContext context property.
 void setLocaleContext(LocaleContext localeContext)
          Overrides the locale.
static void setServletConfig(RenderingContext context, javax.servlet.ServletConfig config)
          Sets the servlet config context property.
 void setServletConfig(javax.servlet.ServletConfig config)
          Sets the servlet config context property.
static void setServletContext(RenderingContext context, javax.servlet.ServletContext servletContext)
          Sets the ServletContext context property.
 void setServletContext(javax.servlet.ServletContext servletContext)
          Sets the ServletContext context property.
static void setServletRequest(RenderingContext context, javax.servlet.ServletRequest request)
          Sets the servlet request context property.
 void setServletRequest(javax.servlet.ServletRequest request)
          Sets the servlet request context property.
static void setServletResponse(RenderingContext context, javax.servlet.ServletResponse response)
          Sets the servlet response context property.
 void setServletResponse(javax.servlet.ServletResponse response)
          Sets the servlet response context property.
 
Methods inherited from class oracle.cabo.ui.RootRenderingContext
clone, createOutputMethod, getAgent, getConfiguration, getDataObject, getDataObject, getDefaultDataProviderSize, getDefaultNodeStackSize, getDefaultPropertyMapSize, getErrorLog, getFacet, getImageContext, getLookAndFeel, getOutputMethod, getParentContext, getRendererManager, getStyleContext, getURLEncoder, prepareOutput, resetProperties, setConfiguration, setConfiguration, setDataObject, setDataObjectDictionary, setErrorLog, setFacet, setURLEncoder, transformName
 
Methods inherited from class oracle.cabo.ui.RenderedNodeRenderingContext
getLocalProperty, getRenderedAncestorNode, getRenderedAncestorNodeCount, popRenderedChild, pushRenderedChild, reset, setLocalProperty, setProperty
 
Methods inherited from class oracle.cabo.ui.LogicalNodeRenderingContext
addDataProvider, getAncestorNode, getAncestorNodeCount, getCurrentDataObject, getPath, popChild, pushChild, setCurrentDataObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.cabo.style.StyleContext
setProperty
 
Methods inherited from interface oracle.cabo.image.ImageContext
setProperty
 

Field Detail

JSP_PAGE_CONTEXT_PROPERTY

public static final java.lang.String JSP_PAGE_CONTEXT_PROPERTY
TYPE: PageContext

JSP_PAGE_PROPERTY

public static final java.lang.String JSP_PAGE_PROPERTY
TYPE: Object

SERVLET_CONFIG_PROPERTY

public static final java.lang.String SERVLET_CONFIG_PROPERTY
TYPE: ServletConfig

SERVLET_CONTEXT_PROPERTY

public static final java.lang.String SERVLET_CONTEXT_PROPERTY
TYPE: ServletContext

SERVLET_REQUEST_PROPERTY

public static final java.lang.String SERVLET_REQUEST_PROPERTY
TYPE: ServletRequest

SERVLET_RESPONSE_PROPERTY

public static final java.lang.String SERVLET_RESPONSE_PROPERTY
TYPE: ServletResponse

HTTP_SESSION_PROPERTY

public static final java.lang.String HTTP_SESSION_PROPERTY
TYPE: HttpSession
Constructor Detail

ServletRenderingContext

public ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext)
Creates a rendering context off a JSP PageContext.

ServletRenderingContext

public ServletRenderingContext(javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               javax.servlet.ServletConfig config)
Creates a rendering context for a Servlet request.
Parameters:
request - the ServletRequest object
response - the ServletResponse object
config - the ServletConfig object (optional)

ServletRenderingContext

public ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext,
                               RendererManager manager)
Deprecated. Let the RendererManager default.

Creates a rendering context off a JSP PageContext.

ServletRenderingContext

public ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext,
                               java.lang.String mimeType)
Deprecated. Let the mime type default.

Creates a rendering context off a JSP PageContext.

ServletRenderingContext

public ServletRenderingContext(javax.servlet.jsp.PageContext jspPageContext,
                               java.lang.String mimeType,
                               RendererManager manager)
Deprecated. Let the mime type and RendererManager both default.

Creates a rendering context off a JSP PageContext.

ServletRenderingContext

public ServletRenderingContext(javax.servlet.Servlet servlet,
                               javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               java.io.PrintWriter out)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse()

Creates a rendering context for a Servlet request, defaulting the MIME type to "text/html".

ServletRenderingContext

public ServletRenderingContext(javax.servlet.Servlet servlet,
                               javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               java.io.PrintWriter out,
                               RendererManager manager)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager default

Creates a rendering context for a Servlet request, defaulting the MIME type to "text/html".

ServletRenderingContext

public ServletRenderingContext(javax.servlet.Servlet servlet,
                               javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               java.io.PrintWriter out,
                               java.lang.String mimeType)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the mime type default.

Creates a rendering context for a Servlet request.

ServletRenderingContext

public ServletRenderingContext(javax.servlet.Servlet servlet,
                               javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               java.io.PrintWriter out,
                               java.lang.String mimeType,
                               RendererManager manager)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.

Creates a rendering context for a Servlet request.
Parameters:
servlet - the ServletConfig is obtained from this servlet
manager - maybe null
See Also:
Servlet.getServletConfig()

ServletRenderingContext

public ServletRenderingContext(javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               javax.servlet.ServletConfig config,
                               java.io.PrintWriter out,
                               java.lang.String mimeType,
                               RendererManager manager)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.

Creates a rendering context for a Servlet request. This calls the 8 argument constructor.
Parameters:
request. - the Agent and LocaleContext is determined from this request.
manager - maybe null

ServletRenderingContext

public ServletRenderingContext(javax.servlet.ServletRequest request,
                               javax.servlet.ServletResponse response,
                               javax.servlet.ServletConfig config,
                               java.io.PrintWriter out,
                               java.lang.String mimeType,
                               Agent agent,
                               LocaleContext localeContext,
                               RendererManager manager)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.

Creates a rendering context for a Servlet request.
Parameters:
manager - maybe null

ServletRenderingContext

protected ServletRenderingContext(javax.servlet.ServletRequest request,
                                  javax.servlet.ServletResponse response,
                                  javax.servlet.ServletConfig config,
                                  java.io.PrintWriter out,
                                  java.lang.String mimeType,
                                  Agent agent,
                                  LocaleContext localeContext,
                                  RendererManager manager,
                                  ErrorLog errorLog,
                                  URLEncoder urlEncoder)
Deprecated. provide the PrintWriter via prepareOutput(), or just use prepareResponse(); let the RendererManager and mime type default.

Creates a rendering context for a Servlet request.
Parameters:
manager - maybe null
Method Detail

prepareResponse

public final void prepareResponse(java.lang.String encoding,
                                  boolean setHeaders)
                           throws java.io.IOException
Prepares the response for a page.
Parameters:
encoding - the desired character encoding
setHeaders - if true, the content type header will be set; this must be false if output has already been committed to the page.

finishResponse

public final void finishResponse()
                          throws java.io.IOException
Finishes a response by closing any writers opened by this rendering context. If you call prepareResponse, you must call this method.

getLocaleContext

public LocaleContext getLocaleContext()
Returns the LocaleContext that should be used for rendering. Defaults off the servlet request parameters.
Overrides:
getLocaleContext in class RootRenderingContext

setLocaleContext

public void setLocaleContext(LocaleContext localeContext)
Overrides the locale. Clients should generally let the locale default off the servlet request paremeters.

setServletRequest

public static void setServletRequest(RenderingContext context,
                                     javax.servlet.ServletRequest request)
Sets the servlet request context property.

getServletRequest

public static javax.servlet.ServletRequest getServletRequest(RenderingContext context)
Gets the servlet request context property.

setServletRequest

public final void setServletRequest(javax.servlet.ServletRequest request)
Sets the servlet request context property.

getServletRequest

public final javax.servlet.ServletRequest getServletRequest()
Gets the servlet request context property.

setServletResponse

public static void setServletResponse(RenderingContext context,
                                      javax.servlet.ServletResponse response)
Sets the servlet response context property.

getServletResponse

public static javax.servlet.ServletResponse getServletResponse(RenderingContext context)
Gets the servlet request context property.

setServletResponse

public final void setServletResponse(javax.servlet.ServletResponse response)
Sets the servlet response context property.

getServletResponse

public final javax.servlet.ServletResponse getServletResponse()
Gets the servlet request context property.

setServletConfig

public static void setServletConfig(RenderingContext context,
                                    javax.servlet.ServletConfig config)
Sets the servlet config context property.

getServletConfig

public static javax.servlet.ServletConfig getServletConfig(RenderingContext context)
Gets the servlet config context property.

setServletConfig

public final void setServletConfig(javax.servlet.ServletConfig config)
Sets the servlet config context property.

getServletConfig

public final javax.servlet.ServletConfig getServletConfig()
Gets the servlet config context property.

setServletContext

public static void setServletContext(RenderingContext context,
                                     javax.servlet.ServletContext servletContext)
Sets the ServletContext context property.

getServletContext

public static javax.servlet.ServletContext getServletContext(RenderingContext context)
Gets the ServletContext context property.

setServletContext

public final void setServletContext(javax.servlet.ServletContext servletContext)
Sets the ServletContext context property.

getServletContext

public final javax.servlet.ServletContext getServletContext()
Gets the ServletContext context property.

setHttpSession

public static void setHttpSession(RenderingContext context,
                                  javax.servlet.http.HttpSession session)
Sets the HttpSession context property.

getHttpSession

public static javax.servlet.http.HttpSession getHttpSession(RenderingContext context)
Gets the HttpSession context property.

setHttpSession

public final void setHttpSession(javax.servlet.http.HttpSession session)
Sets the HttpSession context property.

getHttpSession

public final javax.servlet.http.HttpSession getHttpSession()
Gets the HttpSession context property.

setJspPageContext

public static void setJspPageContext(RenderingContext context,
                                     javax.servlet.jsp.PageContext pageContext)
Sets the JSP PageContext context property.

getJspPageContext

public static javax.servlet.jsp.PageContext getJspPageContext(RenderingContext context)
Gets the JSP PageContext context property.

setJspPageContext

public final void setJspPageContext(javax.servlet.jsp.PageContext pageContext)
Sets the JSP PageContext context property.

getJspPageContext

public final javax.servlet.jsp.PageContext getJspPageContext()
Gets the JSP PageContext context property.

setJspPage

public static void setJspPage(RenderingContext context,
                              java.lang.Object page)
Sets the JSP page context property.

getJspPage

public static java.lang.Object getJspPage(RenderingContext context)
Gets the JSP page context property.

setJspPage

public final void setJspPage(java.lang.Object page)
Sets the JSP page context property.

getJspPage

public final java.lang.Object getJspPage()
Gets the JSP page context property.

getProperty

public java.lang.Object getProperty(java.lang.String namespace,
                                    java.lang.Object key)
Override of RootRenderingContext.getProperty().
Overrides:
getProperty in class RootRenderingContext

getBaseAgent

protected Agent getBaseAgent()
Description copied from class: RootRenderingContext
Returns the "base agent", which has not yet been affected by the choice of a rendering facet. Subclassers should override this method, not getAgent(), to affect the default.
Overrides:
getBaseAgent in class RootRenderingContext

getDefaultLocale

protected java.util.Locale getDefaultLocale()
Returns the locale that will be used if no locale could be identified from the request. The default implementation uses the server's default locale.

createErrorLog

protected ErrorLog createErrorLog()
Responsible for creating an error log for the rendering context. By default, creates an error log that will output to the Servlet's error log.
Overrides:
createErrorLog in class RootRenderingContext

createOutputMethod

protected OutputMethod createOutputMethod()
Description copied from class: RootRenderingContext
Responsible for creating an output method. The default implementation always throws an IllegalStateException. Users usually do not need to overwrite this method; instead they should call RootRenderingContext.prepareOutput(PrintWriter,OutputStream,String,String)
Overrides:
createOutputMethod in class RootRenderingContext
Returns:
Creates an OutputMethod depending on the mime type. The supported mime types are text/plain, text/html and text/xml
Throws:
java.lang.IllegalArgumentException - if mime type is not recognized
See Also:
RootRenderingContext.createOutputMethod()

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.