WebObjects 5.2.3

com.webobjects.jspservlet
Class WOServletAdaptor

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.webobjects.jspservlet.WOServletAdaptor
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class WOServletAdaptor
extends javax.servlet.http.HttpServlet

This class is an adaptor that allows a WebObjects application to appear as a servlet to a servlet container, using the normal doGet/Post methods. This is not a subclass of WOAdaptor. Nor does it participate in the normal WOAdaptor registration/unregistration/request handling. Instead, it is a subclass of HttpServlet. This class is not intended to be subclassed.
It also provides the static APIs embeddedComponentResponse and embeddedDirectActionResponse which, combined with the provided taglib, allows JSP developers to embed WOComponents and Direct Actions in their pages. embeddedComponentResponse and embeddedDirectActionResponse may also be used directly from a Servlet.

See Also:
Serialized Form

Nested Class Summary
static class WOServletAdaptor.JavaArchiveFilter
           
 
Constructor Summary
WOServletAdaptor()
          Empty default constructor that just calls super().
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Method for GET requests.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Method for POST requests.
static String embeddedComponentResponse(String name, HashMap bindings, HashMap extraHeaders, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, javax.servlet.http.HttpServlet servlet, boolean bodyContentOnly, boolean mergeResponseHeaders)
          Returns a String representing the generated content for a given WOComponent with name.
protected static String embeddedComponentResponse(String name, HashMap bindings, HashMap extraHeaders, javax.servlet.jsp.PageContext pageContext, boolean bodyContentOnly, boolean mergeResponseHeaders)
           
static String embeddedDirectActionResponse(String actionName, String className, HashMap formValues, InputStream contentStream, HashMap extraHeaders, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, javax.servlet.http.HttpServlet servlet, boolean bodyContentOnly, boolean mergeResponseHeaders)
          Returns a String representing the generated content for a given direct action with actionName.
protected static String embeddedDirectActionResponse(String actionName, String className, HashMap formValues, InputStream contentStream, HashMap extraHeaders, javax.servlet.jsp.PageContext pageContext, boolean bodyContentOnly, boolean mergeResponseHeaders)
           
 void init()
          Default init method that just calls initStatics
static void initStatics(javax.servlet.ServletContext servletContext)
          Initializes all the appropriate objects so that JSP/Servlet integration works.
 String toString()
          String representation of this class, which includes the classpath, the mainBundlePath, the name of the WOApplication subclass, as well as the ServletConfig and ServletContext
static Object woApplicationObject()
          Returns the WOApplication class (or subclass) used by this application.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WOServletAdaptor

public WOServletAdaptor()
                 throws javax.servlet.ServletException
Empty default constructor that just calls super().

Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws IOException,
                  javax.servlet.ServletException
Method for GET requests. The request will be parsed and translated into a WORequest, and handed off to the WOApplication object. The WOResponse from the WOApplication will be parsed and translated into the HttpServletResponse. This, along with doPost, allows a WOApp to run inside of a Servlet container unchanged.

Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
Throws:
IOException
javax.servlet.ServletException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws IOException,
                   javax.servlet.ServletException
Method for POST requests. The request will be parsed and translated into a WORequest, and handed off to the WOApplication object. The WOResponse from the WOApplication will be parsed and translated into the HttpServletResponse. This, along with doGet, allows a WOApp to run inside of a Servlet container unchanged.

Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
Throws:
IOException
javax.servlet.ServletException

embeddedComponentResponse

protected static String embeddedComponentResponse(String name,
                                                  HashMap bindings,
                                                  HashMap extraHeaders,
                                                  javax.servlet.jsp.PageContext pageContext,
                                                  boolean bodyContentOnly,
                                                  boolean mergeResponseHeaders)

embeddedComponentResponse

public static String embeddedComponentResponse(String name,
                                               HashMap bindings,
                                               HashMap extraHeaders,
                                               javax.servlet.http.HttpServletRequest servletRequest,
                                               javax.servlet.http.HttpServletResponse servletResponse,
                                               javax.servlet.http.HttpServlet servlet,
                                               boolean bodyContentOnly,
                                               boolean mergeResponseHeaders)
Returns a String representing the generated content for a given WOComponent with name. The bindings for that WOComponent are passed in bindings. extraHeaders are headers that will be added to the WORequest as seen by the WOComponent -- note that all the headers that are part of the HttpServletRequest are included automatically. The servletRequest, servletResponse and servlet are passed in for possible use later. If bodyContentOnly is true, only text between the first tag and the last tag will be returned. If mergeResponseHeaders is true, the response headers for the WOComponent will be merged into the servletResponse. Note that all the servlet objects will be stored in the userInfo dictionary argument of WOApplication.responseForComponentWithName. This API is designed to be invoked from inside a Servlet -- for embedding components within JSP pages, use the taglib instead.

Parameters:
name - the name of the WOComponent that should generate the response.
bindings - the bindings for the WOComponent; they can be any type of object.
extraHeaders - extra headers to merge into the WORequest as the WOComponent will see it (optional)
servletRequest - the request object as seen by the invoking Servlet
servletResponse - the response object as seen by the invoking Servlet
servlet - the invoking servlet itself
bodyContentOnly - whether to extract the content of the response for return
mergeResponseHeaders - whether to merge the WOResponse headers into servletResponse
Returns:
String a String representing the component response

embeddedDirectActionResponse

protected static String embeddedDirectActionResponse(String actionName,
                                                     String className,
                                                     HashMap formValues,
                                                     InputStream contentStream,
                                                     HashMap extraHeaders,
                                                     javax.servlet.jsp.PageContext pageContext,
                                                     boolean bodyContentOnly,
                                                     boolean mergeResponseHeaders)

embeddedDirectActionResponse

public static String embeddedDirectActionResponse(String actionName,
                                                  String className,
                                                  HashMap formValues,
                                                  InputStream contentStream,
                                                  HashMap extraHeaders,
                                                  javax.servlet.http.HttpServletRequest servletRequest,
                                                  javax.servlet.http.HttpServletResponse servletResponse,
                                                  javax.servlet.http.HttpServlet servlet,
                                                  boolean bodyContentOnly,
                                                  boolean mergeResponseHeaders)
Returns a String representing the generated content for a given direct action with actionName. The Direct Action className may be specified as well, but is optional. formValues are passed to the direct action as a query string, while the contentString is just passed as regular content -- if the content requires special headers to process use extraHeaders. extraHeaders are headers that will be added to the WORequest as seen by the Direct Action -- note that all the headers that are part of the HttpServletRequest are included automatically. The servletRequest, servletResponse and servlet are passed in for possible use later. If bodyContentOnly is true, only text between the first BODY tag and the last BODY tag will be returned. If mergeResponseHeaders is true, the response headers for the WOComponent will be merged into the servletResponse. Note that all the servlet objects will be stored in the userInfo dictionary argument of WOApplication.responseForComponentWithName. This API is designed to be invoked from inside a Servlet -- for embedding direct actions within JSP pages, use the taglib instead.

Parameters:
actionName - the name of the direct action that should generate the response.
className - the name of the class that the direct action is in (optional)
formValues - the formValues to pass to the direct action, passed as a queryString (optional)
contentStream - the content to pass to the direct action (optional)
extraHeaders - extra headers to merge into the WORequest as the direct action will see it (optional)
servletRequest - the request object as seen by the invoking Servlet
servletResponse - the response object as seen by the invoking Servlet
servlet - the invoking servlet itself
bodyContentOnly - whether to extract the content of the response for return
mergeResponseHeaders - whether to merge the WOResponse headers into servletResponse
Returns:
String a String representing the direct action response.

init

public void init()
          throws javax.servlet.ServletException
Default init method that just calls initStatics

Throws:
javax.servlet.ServletException

initStatics

public static void initStatics(javax.servlet.ServletContext servletContext)
                        throws javax.servlet.UnavailableException
Initializes all the appropriate objects so that JSP/Servlet integration works. Normally, this method should never be called, since either calling embeddedComponentResponse or having the servlet container initialize the WOServletAdaptor object will do everything for you. However, if you are planning on using WebObjects objects directly in either a JSP or Servlet, you must invoke this method first. Further invocations of this method past the first will do nothing.

Throws:
javax.servlet.UnavailableException

toString

public String toString()
String representation of this class, which includes the classpath, the mainBundlePath, the name of the WOApplication subclass, as well as the ServletConfig and ServletContext

Returns:
String the string representation of this class

woApplicationObject

public static Object woApplicationObject()
Returns the WOApplication class (or subclass) used by this application. initStatics, embeddedComponentResponse, embeddedDirectActionResponse, or a Taglib must have been invoked previous to calling this.

Returns:
Object the uncast WOApplication object.

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.