com.sun.grizzly.http.servlet
Class ServletContextImpl

java.lang.Object
  extended by com.sun.grizzly.http.servlet.ServletContextImpl
All Implemented Interfaces:
ServletContext

public class ServletContextImpl
extends Object
implements ServletContext

Author:
Jeanfrancois Arcand

Constructor Summary
ServletContextImpl()
           
 
Method Summary
 Object getAttribute(String name)
          Return the value of the specified context attribute, if any; otherwise return null.
 Enumeration getAttributeNames()
          Return an enumeration of the names of the context attributes associated with this context.
protected  String getBasePath()
          Return the current based path.
 ServletContext getContext(String uri)
          Return a ServletContext object that corresponds to a specified URI on the server.
 String getContextPath()
          
 String getInitParameter(String name)
          Return the value of the specified initialization parameter, or null if this parameter does not exist.
 Enumeration getInitParameterNames()
          Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.
 int getMajorVersion()
          Return the major version of the Java Servlet API that we implement.
 String getMimeType(String file)
          Return the MIME type of the specified file, or null if the MIME type cannot be determined.
 int getMinorVersion()
          Return the minor version of the Java Servlet API that we implement.
 RequestDispatcher getNamedDispatcher(String arg0)
          
 String getRealPath(String path)
          Return the real path for a given virtual path, if possible; otherwise return null.
 RequestDispatcher getRequestDispatcher(String arg0)
          
 URL getResource(String path)
          Return the URL to the resource that is mapped to a specified path.
 InputStream getResourceAsStream(String path)
          Return the requested resource as an InputStream.
 Set getResourcePaths(String path)
          Return a Set containing the resource paths of resources member of the specified collection.
 String getServerInfo()
           
 Servlet getServlet(String name)
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
 String getServletContextName()
          
 Enumeration getServletNames()
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
protected  String getServletPath()
          Set the context-path.
 Enumeration getServlets()
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
 void log(Exception e, String msg)
          
 void log(String string)
          
 void log(String msg, Throwable t)
          
 void removeAttribute(String name)
          Remove the context attribute with the specified name, if any.
 void setAttribute(String name, Object value)
          Bind the specified value with the specified context attribute name, replacing any existing value for that name.
protected  void setBasePath(String basePath)
          Set the basePath used by the getRealPath(java.lang.String).
protected  void setContextPath(String contextPath)
          Programmatically set the context path of the Servlet.
protected  void setInitParameter(HashMap<String,String> parameters)
           
protected  void setServletPath(String servletPath)
          Programmaticaly set the servlet path value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletContextImpl

public ServletContextImpl()
Method Detail

getContextPath

public String getContextPath()

Specified by:
getContextPath in interface ServletContext

setContextPath

protected void setContextPath(String contextPath)
Programmatically set the context path of the Servlet.

Parameters:
contextPath -

getContext

public ServletContext getContext(String uri)
Return a ServletContext object that corresponds to a specified URI on the server. This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher objects or resources from the context. The given path must be absolute (beginning with a "/"), and is interpreted based on our virtual host's document root.

Specified by:
getContext in interface ServletContext
Parameters:
uri - Absolute URI of a resource on the server

getMajorVersion

public int getMajorVersion()
Return the major version of the Java Servlet API that we implement.

Specified by:
getMajorVersion in interface ServletContext

getMinorVersion

public int getMinorVersion()
Return the minor version of the Java Servlet API that we implement.

Specified by:
getMinorVersion in interface ServletContext

getMimeType

public String getMimeType(String file)
Return the MIME type of the specified file, or null if the MIME type cannot be determined.

Specified by:
getMimeType in interface ServletContext
Parameters:
file - Filename for which to identify a MIME type

getResourcePaths

public Set getResourcePaths(String path)
Return a Set containing the resource paths of resources member of the specified collection. Each path will be a String starting with a "/" character. The returned set is immutable.

Specified by:
getResourcePaths in interface ServletContext
Parameters:
path - Collection path TODO: Not yet supported

getResource

public URL getResource(String path)
                throws MalformedURLException
Return the 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.

Specified by:
getResource in interface ServletContext
Parameters:
path - The path to the desired resource
Throws:
MalformedURLException - if the path is not given in the correct form

getResourceAsStream

public InputStream getResourceAsStream(String path)
Return the requested resource as an InputStream. The path must be specified according to the rules described under getResource. If no such resource can be identified, return null.

Specified by:
getResourceAsStream in interface ServletContext
Parameters:
path - The path to the desired resource.

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String arg0)

Specified by:
getRequestDispatcher in interface ServletContext

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String arg0)

Specified by:
getNamedDispatcher in interface ServletContext

getServlet

public Servlet getServlet(String name)
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServlet in interface ServletContext

getServlets

public Enumeration getServlets()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServlets in interface ServletContext

getServletNames

public Enumeration getServletNames()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServletNames in interface ServletContext

log

public void log(String string)

Specified by:
log in interface ServletContext

log

public void log(Exception e,
                String msg)

Specified by:
log in interface ServletContext

log

public void log(String msg,
                Throwable t)

Specified by:
log in interface ServletContext

getRealPath

public String getRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise return null.

Specified by:
getRealPath in interface ServletContext
Parameters:
path - The path to the desired resource

getServerInfo

public String getServerInfo()
Specified by:
getServerInfo in interface ServletContext

getInitParameter

public String getInitParameter(String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist.

Specified by:
getInitParameter in interface ServletContext
Parameters:
name - Name of the initialization parameter to retrieve

getInitParameterNames

public Enumeration getInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.

Specified by:
getInitParameterNames in interface ServletContext

setInitParameter

protected void setInitParameter(HashMap<String,String> parameters)

getAttribute

public Object getAttribute(String name)
Return the value of the specified context attribute, if any; otherwise return null.

Specified by:
getAttribute in interface ServletContext
Parameters:
name - Name of the context attribute to return

getAttributeNames

public Enumeration getAttributeNames()
Return an enumeration of the names of the context attributes associated with this context.

Specified by:
getAttributeNames in interface ServletContext

setAttribute

public void setAttribute(String name,
                         Object value)
Bind the specified value with the specified context attribute name, replacing any existing value for that name.

Specified by:
setAttribute in interface ServletContext
Parameters:
name - Attribute name to be bound
value - New attribute value to be bound

removeAttribute

public void removeAttribute(String name)
Remove the context attribute with the specified name, if any.

Specified by:
removeAttribute in interface ServletContext
Parameters:
name - Name of the context attribute to be removed

getServletContextName

public String getServletContextName()

Specified by:
getServletContextName in interface ServletContext

getServletPath

protected String getServletPath()
Set the context-path. Default is "".


setServletPath

protected void setServletPath(String servletPath)
Programmaticaly set the servlet path value. Default is an empty String.

Parameters:
servletPath -

getBasePath

protected String getBasePath()
Return the current based path.

Returns:
basePath

setBasePath

protected void setBasePath(String basePath)
Set the basePath used by the getRealPath(java.lang.String).

Parameters:
basePath -


Copyright © 2009 SUN Microsystems. All Rights Reserved.