com.sun.portal.desktop
Class DesktopServlet

com.sun.portal.desktop.DesktopServlet
All Implemented Interfaces:
ProviderEditTypes

public class DesktopServlet
implements ProviderEditTypes

The Desktop Servlet is a router of request. It catches request for content and processing and passes them on to the specific provider object. Desktop Servlet understands several actions. Every action has an associated channel name to perform the action on. Actions understood by the Desktop servlet are:

Actions are passed to the servlet via GET or POST parameters. The associated channel name is also passed as a parameter. For example, to perform the content action on the channel name foo, pass in the following parameters to the servlet:

[url to servlet]?action=content&provider=foo

The content, edit, and process actions map directly to method calls into the Provider API (PAPI). For example, for an action equal to process and a channel name equal to foo, the Desktop servlet will get a handle to the provider object associated with the channel name foo, and call the Provider.processEdit() method.

For such desktop actions that map to PAPI method calls, the servlet passes an HTTP request and response object to the respective Provider method. These objects are not the same objects passed into the servlet. The request and response objects passed to provider objects from the servlet are wrappers around the original request and response passed into the servlet. This is because there is certain functionality that is available from request and response objects that is not applicable to a provider. See the Javadocs for the class Provider for more information.

The HTTP parameters in the original request object are processed before they are copied to the "wrapper" servlet request and response objects. As part of this processing, the parameters are decoded from the character set encoding used to represent the page into Unicode that is used in Java String objects. Therefore, the parameters that are passed to the providers are all stored as Unicode, and the provider does not have to do any decoding of its own related to the character encoding for the page.

The servlet also keeps track of the last top-level container/channel that is accessed. It does it as following:
If the "provider" parameter is absent in the request, the servlet assumes it is equal to the value of the last request where the "action" parameter's value was "content". If there is no such last request, then a default channel is assumed. Specifying the parameter "action=content" causes the servlet to set the last accessed channel name to the value of the "provider" parameter. This can be overriden by additionally specifying the parameter "last" in the request. When set to false, the servlet will not set the last channel to the value of the "provider" parameter. If not specified, the default setting is "last=true", and the last accessed channel is set to the value of the "provider" parameter. Note: This only applies when the "action" parameter is equal to "content"; the last accessed channel is only set when the "action" parameter is equal to "content".

Various scenarios:

  1. <desktopURL> (= <desktopURL>?provider=<default channel>)
    No last accessed channel set. The "provider" parameter is assumed to be the default channel. The last accessed channel is set to the name of the default channel.
  2. <desktopURL> (= <desktopURL>?provider=<last acccessed channel>)
    The "provider" parameter is absent, so it is assumed to be the value of the last accecssed channel set in step #1.
  3. <desktopURL>?action=content&provider=foo
    The last accessed channel is set to foo.
  4. <desktopURL>
    The "provider" parameter is absent, so it is assumed to be the value of the last accessed channel set in step #3 (foo).
  5. <desktopURL>?action=edit&provider=bar
    Last accessed channel is NOT set to bar, since the "action" was "edit".
  6. <desktopURL>?action=process OR <desktopURL>?action=edit
    Invalid, must specify a "provider" parameter. Default or last accessed channel is not assumed when "action" equals "edit" or "process".

This class also creates a single instance of error provider object, that is used by all the providers. Whenever a provider throws an exception it is populated all the way up to the DesktopServlet which in turn invokes the error provider which displays a generic error template. The stack trace can also be viewed by looking at the source of the error template (it is defined as a markup but commented out so that it does not appear on the browser).

See Also:
Provider

Fields inherited from interface com.sun.portal.providers.ProviderEditTypes
EDIT_COMPLETE, EDIT_SUBSET
 
Constructor Summary
DesktopServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 void init(javax.servlet.ServletConfig config)
           
static void printConfigAttributes(javax.servlet.ServletContext sc)
           
 

Constructor Detail

DesktopServlet

public DesktopServlet()
Method Detail

printConfigAttributes

public static void printConfigAttributes(javax.servlet.ServletContext sc)

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   IOException