org.apache.tapestry.web
Interface WebContext

All Superinterfaces:
AttributeHolder, Describable, InitializationParameterHolder
All Known Implementing Classes:
PortletWebContext, ServletWebContext

public interface WebContext
extends AttributeHolder, InitializationParameterHolder, Describable

A representation of a set of servlets (or portlets) packaged together as a web application archive. Attributes stored within the context are global to all 'lets (but not distributed across a server cluster).

Author:
Howard M. Lewis Ship

Method Summary
 String getMimeType(String resourcePath)
          Returns the MIME type of the specified file, or null if the MIME type is not known.
 String getRealPath(String path)
          Returns a String containing the real path for a given virtual path.
 URL getResource(String path)
          Returns a URL to the resource that is mapped to a specified path.
 InputStream getResourceAsStream(String path)
          Returns the resource located at the named path as an InputStream object.
 Set getResourcePaths(String path)
          Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.
 
Methods inherited from interface org.apache.tapestry.web.AttributeHolder
getAttribute, getAttributeNames, setAttribute
 
Methods inherited from interface org.apache.tapestry.web.InitializationParameterHolder
getInitParameterNames, getInitParameterValue
 
Methods inherited from interface org.apache.tapestry.describe.Describable
describeTo
 

Method Detail

getResource

URL getResource(String path)
Returns a URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.


getMimeType

String getMimeType(String resourcePath)
Returns the MIME type of the specified file, or null if the MIME type is not known.


getResourcePaths

Set getResourcePaths(String path)
Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a slash (/). The returned paths are all relative to the root of the web application and have a leading '/'.

Parameters:
path - partial path used to match the resources, which must start with a '/'
Returns:
a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.

getResourceAsStream

InputStream getResourceAsStream(String path)
Returns the resource located at the named path as an InputStream object.

Parameters:
path - a String specifying the path to the resource
Returns:
the InputStream returned to the servlet, or null if no resource exists at the specified path

getRealPath

String getRealPath(String path)
Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for "http://host/contextPath/index.html", where contextPath is the context path of this WebContext.

Parameters:
path - a String specifying a virtual path
Returns:
a String specifying the real path, or null if the translation cannot be performed


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.