com.sun.webui.theme
Class ThemeServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.sun.webui.theme.ThemeServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ThemeServlet
extends javax.servlet.http.HttpServlet

ThemeServlet is required by the com.sun.webui components to resolve references to resources that exist in a jar. This servlet implementation is needed because a JSF FacesServlet cannot be extended and because a javax.servlet.ServletContext.getResourceAsStream, does not search for a resource within jars that are on the application's class path.

Not all theme resources that are referenced by a component are located in jars. An application may override theme resources by defining those resources in the application via a theme resourece bundle.

Themes consist of both resources that are used directly by the Java classes at runtime (for example property files) and resources that are requested by the application users' browser (for example image files). The ThemeServlet class makes the resources in the Theme jar available over HTTP. This requires that the the classpath of this servlet be the same as the class path of the application. The situation should not exist where a different jar is used during the server side page assembly to acquire a theme resource reference and then a different jar is used by this servlet to obtain the actual bits of that resource when the page is rendering in a browser.

How to configure the ThemeServlet

Define an entry for the servlet in the web application's configuration file (web.xml). Configure one instance of this servlet as follows:

     <servlet>
         <servlet-name>ThemeServlet</servlet-name>
         <servlet-class>com.sun.webui.jsf.theme.ThemeServlet</servlet-class>
      </servlet>
 
     <servlet-mapping>
         <servlet-name>ThemeServlet</servlet-name>
         <url-pattern>/theme/*</url-pattern>
     </servlet-mapping>
   

Note that the url-pattern must be specifed in a slightly different manner for the ThemeContext context-param com.sun.webui.theme.THEME_SERVLET_CONTEXT

     <context-param>
        <param-name>com.sun.webui.theme.THEME_SERVLET_CONTEXT<param-name>
        <param-value>theme<param-value>
    <context-param>
 
The actual value of the url-pattern is does not have to be /theme/* it just must be the same for the servlet-mapping and the THEME_SERVLET_CONTEXT context-param.

See Also:
ThemeContext, Theme, ThemeFactory, Serialized Form

Constructor Summary
ThemeServlet()
           
 
Method Summary
 long getLastModified(javax.servlet.http.HttpServletRequest request)
          Return the timestamp for when resources provided by this servlet were last modified.
 java.lang.String getServletInfo()
          Returns a short description of the servlet.
 void init(javax.servlet.ServletConfig config)
          Initializes the ThemeServlet
 
Methods inherited from class javax.servlet.http.HttpServlet
service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThemeServlet

public ThemeServlet()
Method Detail

getServletInfo

public java.lang.String getServletInfo()
Returns a short description of the servlet.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
A String that names the Servlet

init

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

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - The ServletConfig object
Throws:
javax.servlet.ServletException

getLastModified

public long getLastModified(javax.servlet.http.HttpServletRequest request)
Return the timestamp for when resources provided by this servlet were last modified. By default, this will be the timestamp when this servlet was first loaded at the deployment of the containing webapp.

Overrides:
getLastModified in class javax.servlet.http.HttpServlet
Parameters:
request - The HttpServletRequest being processed
Returns:
The date when the resource was last modified


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.