org.apache.jasper.servlet

Class JspCServletContext

public class JspCServletContext extends Object implements ServletContext

Simple ServletContext implementation without HTTP-specific methods.

Author: Peter Rossbach (pr@webapp.de)

Field Summary
protected HashtablemyAttributes
Servlet context attributes.
protected PrintWritermyLogWriter
The log writer we will write log messages to.
protected URLmyResourceBaseURL
The base URL (document root) for this context.
Constructor Summary
JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL)
Create a new instance of this ServletContext implementation.
Method Summary
ObjectgetAttribute(String name)
Return the specified context attribute, if any.
EnumerationgetAttributeNames()
Return an enumeration of context attribute names.
ServletContextgetContext(String uripath)
Return the servlet context for the specified path.
StringgetContextPath()
Return the context path.
StringgetInitParameter(String name)
Return the specified context initialization parameter.
EnumerationgetInitParameterNames()
Return an enumeration of the names of context initialization parameters.
intgetMajorVersion()
Return the Servlet API major version number.
StringgetMimeType(String file)
Return the MIME type for the specified filename.
intgetMinorVersion()
Return the Servlet API minor version number.
RequestDispatchergetNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name.
StringgetRealPath(String path)
Return the real path for the specified context-relative virtual path.
RequestDispatchergetRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path.
URLgetResource(String path)
Return a URL object of a resource that is mapped to the specified context-relative path.
InputStreamgetResourceAsStream(String path)
Return an InputStream allowing access to the resource at the specified context-relative path.
SetgetResourcePaths(String path)
Return the set of resource paths for the "directory" at the specified context path.
StringgetServerInfo()
Return descriptive information about this server.
ServletgetServlet(String name)
Return a null reference for the specified servlet name.
StringgetServletContextName()
Return the name of this servlet context.
EnumerationgetServletNames()
Return an empty enumeration of servlet names.
EnumerationgetServlets()
Return an empty enumeration of servlets.
voidlog(String message)
Log the specified message.
voidlog(Exception exception, String message)
Log the specified message and exception.
voidlog(String message, Throwable exception)
Log the specified message and exception.
voidremoveAttribute(String name)
Remove the specified context attribute.
voidsetAttribute(String name, Object value)
Set or replace the specified context attribute.

Field Detail

myAttributes

protected Hashtable myAttributes
Servlet context attributes.

myLogWriter

protected PrintWriter myLogWriter
The log writer we will write log messages to.

myResourceBaseURL

protected URL myResourceBaseURL
The base URL (document root) for this context.

Constructor Detail

JspCServletContext

public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL)
Create a new instance of this ServletContext implementation.

Parameters: aLogWriter PrintWriter which is used for log() calls aResourceBaseURL Resource base URL

Method Detail

getAttribute

public Object getAttribute(String name)
Return the specified context attribute, if any.

Parameters: name Name of the requested attribute

getAttributeNames

public Enumeration getAttributeNames()
Return an enumeration of context attribute names.

getContext

public ServletContext getContext(String uripath)
Return the servlet context for the specified path.

Parameters: uripath Server-relative path starting with '/'

getContextPath

public String getContextPath()
Return the context path.

getInitParameter

public String getInitParameter(String name)
Return the specified context initialization parameter.

Parameters: name Name of the requested parameter

getInitParameterNames

public Enumeration getInitParameterNames()
Return an enumeration of the names of context initialization parameters.

getMajorVersion

public int getMajorVersion()
Return the Servlet API major version number.

getMimeType

public String getMimeType(String file)
Return the MIME type for the specified filename.

Parameters: file Filename whose MIME type is requested

getMinorVersion

public int getMinorVersion()
Return the Servlet API minor version number.

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name.

Parameters: name Name of the requested servlet

getRealPath

public String getRealPath(String path)
Return the real path for the specified context-relative virtual path.

Parameters: path The context-relative virtual path to resolve

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path.

Parameters: path Context-relative path for which to acquire a dispatcher

getResource

public URL getResource(String path)
Return a URL object of a resource that is mapped to the specified context-relative path.

Parameters: path Context-relative path of the desired resource

Throws: MalformedURLException if the resource path is not properly formed

getResourceAsStream

public InputStream getResourceAsStream(String path)
Return an InputStream allowing access to the resource at the specified context-relative path.

Parameters: path Context-relative path of the desired resource

getResourcePaths

public Set getResourcePaths(String path)
Return the set of resource paths for the "directory" at the specified context path.

Parameters: path Context-relative base path

getServerInfo

public String getServerInfo()
Return descriptive information about this server.

getServlet

public Servlet getServlet(String name)

Deprecated: This method has been deprecated with no replacement

Return a null reference for the specified servlet name.

Parameters: name Name of the requested servlet

getServletContextName

public String getServletContextName()
Return the name of this servlet context.

getServletNames

public Enumeration getServletNames()

Deprecated: This method has been deprecated with no replacement

Return an empty enumeration of servlet names.

getServlets

public Enumeration getServlets()

Deprecated: This method has been deprecated with no replacement

Return an empty enumeration of servlets.

log

public void log(String message)
Log the specified message.

Parameters: message The message to be logged

log

public void log(Exception exception, String message)

Deprecated: Use log(String,Throwable) instead

Log the specified message and exception.

Parameters: exception The exception to be logged message The message to be logged

log

public void log(String message, Throwable exception)
Log the specified message and exception.

Parameters: message The message to be logged exception The exception to be logged

removeAttribute

public void removeAttribute(String name)
Remove the specified context attribute.

Parameters: name Name of the attribute to remove

setAttribute

public void setAttribute(String name, Object value)
Set or replace the specified context attribute.

Parameters: name Name of the context attribute to set value Corresponding attribute value

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.