com.arsdigita.web
Class Web

java.lang.Object
  extended bycom.arsdigita.web.Web

public class Web
extends Object

An entry point for functions of the web package.

Author:
Rafael Schloming <rhs@mit.edu>, Justin Ross <jross@redhat.com>

Field Summary
static String ROOT_WEBAPP
           
static String versionId
           
 
Constructor Summary
Web()
           
 
Method Summary
static URL findResource(String resource)
          Finds a concrete URL corresponding to an abstract webapp resource.
static URL findResource(String[] webapps, String path)
          Finds a concrete URL corresponding to an abstract webapp resource.
static InputStream findResourceAsStream(String resource)
          Follows the same rules as findResource(String), but instead returns an input stream for reading the resource
static InputStream findResourceAsStream(String[] webapps, String path)
          Follows the same rules as findResource(String[], String), but instead returns an input stream for reading the resource
static javax.servlet.RequestDispatcher findResourceDispatcher(String resource)
          Follows the same rules as findResource(String), but instead returns a request dispatcher for serving the resource
static javax.servlet.RequestDispatcher findResourceDispatcher(String[] webapps, String path)
          Follows the same rules as findResource(String[], String), but instead returns a request dispatcher for serving the resource
static WebConfig getConfig()
          Gets the configuration record for code in the web package.
static WebContext getContext()
          Gets the web context object from the current thread.
static javax.servlet.http.HttpServletRequest getRequest()
          Gets the servlet request object of the current thread.
static javax.servlet.ServletContext getServletContext()
          Gets the servlet context of the current thread.
static javax.servlet.ServletContext getServletContext(String uri)
          Gets the servlet context matching a URI.
static UserContext getUserContext()
          Gets the user context object of the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

ROOT_WEBAPP

public static final String ROOT_WEBAPP
See Also:
Constant Field Values
Constructor Detail

Web

public Web()
Method Detail

getContext

public static final WebContext getContext()
Gets the web context object from the current thread.

Returns:
A WebContext object; it cannot be null

getConfig

public static final WebConfig getConfig()
Gets the configuration record for code in the web package.

Returns:
A WebConfig configuration record; it cannot be null

getRequest

public static final javax.servlet.http.HttpServletRequest getRequest()
Gets the servlet request object of the current thread.

Returns:
The current HttpServletRequest; it can be null

getServletContext

public static final javax.servlet.ServletContext getServletContext()
Gets the servlet context of the current thread.

Returns:
The current ServletContext; it can be null

getServletContext

public static final javax.servlet.ServletContext getServletContext(String uri)
Gets the servlet context matching a URI. The URI is relative to the root of the server and must start and end with a '/'. This should be used in preference to ServletContext#getContext(String) since on all versions of Tomcat, this fails if the path of the context requested is below the current context.

Parameters:
uri - the context URI
Returns:
the servlet context matching uri, or null

getUserContext

public static final UserContext getUserContext()
Gets the user context object of the current thread.

Returns:
The current UserContext object; it can be null

findResource

public static URL findResource(String resource)
Finds a concrete URL corresponding to an abstract webapp resource. The format of the resource is as follows: "/[webapp list]/[path]". The 'webapp list' component is a comma separate list of webapps to search for the second component 'path'. So, if the 'resource' is:
  /myproj,ccm-cms,ROOT/__ccm__/apps/content-section/index.sl
 
then this method will look for resources at
  /myproj/__ccm__/apps/content-section/index.sl
  /ccm-cms/__ccm__/apps/content-section/index.sl
  /ROOT/__ccm__/apps/content-section/index.sl
 

Parameters:
resource - the resource name
Returns:
the URL for the resource, or null

findResource

public static URL findResource(String[] webapps,
                               String path)
Finds a concrete URL corresponding to an abstract webapp resource. The first argument is a list of webapp paths to search through for the path. So if the webapps param is { 'myproj', 'ccm-cms', 'ROOT' } and the path parma is '/__ccm__/apps/content-section/index.xsl' then the paths that are searched are:
  /myproj/__ccm__/apps/content-section/index.sl
  /ccm-cms/__ccm__/apps/content-section/index.sl
  /ROOT/__ccm__/apps/content-section/index.sl
 

Parameters:
webapps - the list of webapps
path - the resource path
Returns:
the URL for the resource, or null

findResourceAsStream

public static InputStream findResourceAsStream(String resource)
                                        throws IOException
Follows the same rules as findResource(String), but instead returns an input stream for reading the resource

Parameters:
resource - the resource name
Returns:
the input stream for the resource, or null
Throws:
IOException

findResourceAsStream

public static InputStream findResourceAsStream(String[] webapps,
                                               String path)
                                        throws IOException
Follows the same rules as findResource(String[], String), but instead returns an input stream for reading the resource

Parameters:
webapps - the list of webapps
path - the resource path
Returns:
the input stream for the resource, or null
Throws:
IOException

findResourceDispatcher

public static javax.servlet.RequestDispatcher findResourceDispatcher(String resource)
Follows the same rules as findResource(String), but instead returns a request dispatcher for serving the resource

Parameters:
resource - the resource name
Returns:
the request dispatcher for the resource, or null

findResourceDispatcher

public static javax.servlet.RequestDispatcher findResourceDispatcher(String[] webapps,
                                                                     String path)
Follows the same rules as findResource(String[], String), but instead returns a request dispatcher for serving the resource

Parameters:
webapps - the list of webapps
path - the resource path
Returns:
the request dispatcher for the resource, or null


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC