|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jasper.servlet.JspCServletContext
public class JspCServletContext
Simple ServletContext
implementation without
HTTP-specific methods.
Field Summary | |
---|---|
protected Hashtable |
myAttributes
Servlet context attributes. |
protected PrintWriter |
myLogWriter
The log writer we will write log messages to. |
protected URL |
myResourceBaseURL
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 | |
---|---|
void |
addFilter(String filterName,
String description,
String className,
Map<String,String> initParameters)
Adds the filter with the given name, description, and class name to this servlet context. |
void |
addFilterMapping(String filterName,
String[] urlPatterns,
String[] servletNames,
EnumSet<DispatcherType> dispatcherTypes,
boolean isMatchAfter)
Adds a filter mapping with the given url patterns, servlet names, and dispatcher types for the filter with the given filter name to this servlet context. |
void |
addServlet(String servletName,
String description,
String className,
Map<String,String> initParameters,
int loadOnStartup)
Adds the servlet with the given name, description, and class name to this servlet context. |
void |
addServletMapping(String servletName,
String[] urlPatterns)
Adds a servlet mapping with the given url patterns for the servlet with the given servlet name to this servlet context. |
Object |
getAttribute(String name)
Return the specified context attribute, if any. |
Enumeration |
getAttributeNames()
Return an enumeration of context attribute names. |
ServletContext |
getContext(String uripath)
Return the servlet context for the specified path. |
String |
getContextPath()
Returns the context path of the web application. |
String |
getInitParameter(String name)
Return the specified context initialization parameter. |
Enumeration |
getInitParameterNames()
Return an enumeration of the names of context initialization parameters. |
int |
getMajorVersion()
Return the Servlet API major version number. |
String |
getMimeType(String file)
Return the MIME type for the specified filename. |
int |
getMinorVersion()
Return the Servlet API minor version number. |
RequestDispatcher |
getNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name. |
String |
getRealPath(String path)
Return the real path for the specified context-relative virtual path. |
RequestDispatcher |
getRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path. |
URL |
getResource(String path)
Return a URL object of a resource that is mapped to the specified context-relative path. |
InputStream |
getResourceAsStream(String path)
Return an InputStream allowing access to the resource at the specified context-relative path. |
Set |
getResourcePaths(String path)
Return the set of resource paths for the "directory" at the specified context path. |
String |
getServerInfo()
Return descriptive information about this server. |
Servlet |
getServlet(String name)
Deprecated. This method has been deprecated with no replacement |
String |
getServletContextName()
Return the name of this servlet context. |
Enumeration |
getServletNames()
Deprecated. This method has been deprecated with no replacement |
Enumeration |
getServlets()
Deprecated. This method has been deprecated with no replacement |
void |
log(Exception exception,
String message)
Deprecated. Use log(String,Throwable) instead |
void |
log(String message)
Log the specified message. |
void |
log(String message,
Throwable exception)
Log the specified message and exception. |
void |
removeAttribute(String name)
Remove the specified context attribute. |
void |
setAttribute(String name,
Object value)
Set or replace the specified context attribute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Hashtable myAttributes
protected PrintWriter myLogWriter
protected URL myResourceBaseURL
Constructor Detail |
---|
public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL)
aLogWriter
- PrintWriter which is used for log()
callsaResourceBaseURL
- Resource base URLMethod Detail |
---|
public Object getAttribute(String name)
getAttribute
in interface ServletContext
name
- Name of the requested attribute
Object
containing the value
of the attribute, or null
if no attribute exists matching the given
nameServletContext.getAttributeNames()
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletContext
Enumeration
of attribute
namesServletContext.getAttribute(java.lang.String)
public String getContextPath()
getContextPath
in interface ServletContext
public ServletContext getContext(String uripath)
getContext
in interface ServletContext
uripath
- Server-relative path starting with '/'
ServletContext
object that
corresponds to the named URL, or null if either
none exists or the container wishes to restrict
this access.RequestDispatcher
public String getInitParameter(String name)
getInitParameter
in interface ServletContext
name
- Name of the requested parameter
String
containing at least the
servlet container name and version numberServletConfig.getInitParameter(java.lang.String)
public Enumeration getInitParameterNames()
getInitParameterNames
in interface ServletContext
Enumeration
of String
objects containing the names of the context's
initialization parametersServletConfig.getInitParameter(java.lang.String)
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public String getMimeType(String file)
getMimeType
in interface ServletContext
file
- Filename whose MIME type is requested
String
specifying the file's MIME typepublic int getMinorVersion()
getMinorVersion
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String name)
getNamedDispatcher
in interface ServletContext
name
- Name of the requested servlet
RequestDispatcher
object
that acts as a wrapper for the named servlet,
or null
if the ServletContext
cannot return a RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
,
ServletConfig.getServletName()
public String getRealPath(String path)
getRealPath
in interface ServletContext
path
- The context-relative virtual path to resolve
String
specifying the real path,
or null if the translation cannot be performedpublic RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletContext
path
- Context-relative path for which to acquire a dispatcher
RequestDispatcher
object
that acts as a wrapper for the resource
at the specified path, or null
if
the ServletContext
cannot return
a RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
public URL getResource(String path) throws MalformedURLException
getResource
in interface ServletContext
path
- Context-relative path of the desired resource
null
if there is no resource
at that path
MalformedURLException
- if the resource path is
not properly formedpublic InputStream getResourceAsStream(String path)
getResourceAsStream
in interface ServletContext
path
- Context-relative path of the desired resource
InputStream
returned to the
servlet, or null
if no resource
exists at the specified pathpublic Set getResourcePaths(String path)
getResourcePaths
in interface ServletContext
path
- Context-relative base path
public String getServerInfo()
getServerInfo
in interface ServletContext
String
containing at least the
servlet container name and version numberpublic Servlet getServlet(String name) throws ServletException
getServlet
in interface ServletContext
name
- Name of the requested servlet
ServletException
public String getServletContextName()
getServletContextName
in interface ServletContext
public Enumeration getServletNames()
getServletNames
in interface ServletContext
public Enumeration getServlets()
getServlets
in interface ServletContext
public void log(String message)
log
in interface ServletContext
message
- The message to be loggedpublic void log(Exception exception, String message)
log
in interface ServletContext
exception
- The exception to be loggedmessage
- The message to be loggedpublic void log(String message, Throwable exception)
log
in interface ServletContext
message
- The message to be loggedexception
- The exception to be loggedpublic void removeAttribute(String name)
removeAttribute
in interface ServletContext
name
- Name of the attribute to removepublic void setAttribute(String name, Object value)
setAttribute
in interface ServletContext
name
- Name of the context attribute to setvalue
- Corresponding attribute valuepublic void addFilter(String filterName, String description, String className, Map<String,String> initParameters)
javax.servlet.ServletContext
addFilter
in interface ServletContext
filterName
- the name of the filterdescription
- the description of the filterclassName
- the fully qualified class name of the filterinitParameters
- the initialization parameters of the filter,
or null if the filter does not need anypublic void addFilterMapping(String filterName, String[] urlPatterns, String[] servletNames, EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter)
javax.servlet.ServletContext
The filter with the given name may have been declared in the
deployment descriptor or one of the web fragments of this servlet
context, or may be added using addFilter
. It is
legal to add a filter mapping for a filter that has not yet been added.
Filter mappings added via this method will be matched against requests in the same order in which they were added.
Depending on the value of the isMatchAfter parameter, the given filter mapping will be considered after or before any declared filter mappings of this servlet context.
addFilterMapping
in interface ServletContext
filterName
- the name of the filter for which the filter
mapping is addedurlPatterns
- the url patterns of the filter mappingservletNames
- the servlet names of the filter mappingdispatcherTypes
- the dispatcher types of the filter mapping,
or null if the default DispatcherType.REQUEST is to be usedisMatchAfter
- true if the given filter mapping should be matched
against requests after any declared filter mappings of this servlet
context, and false if it is supposed to be matched before any declared
filter mappings of this servlet contextpublic void addServlet(String servletName, String description, String className, Map<String,String> initParameters, int loadOnStartup)
javax.servlet.ServletContext
If loadOnStartup is a positive integer or zero, it
indicates to the container the initialization priority of the
servlet. In this case, the container must instantiate and initialize
the servlet during the initialization phase of this servlet context,
that is, after it has invoked all of the ServletContextListeners
configured for this servlet context at their
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method.
If loadOnStartup is a negative integer, the container is free to instantiate and initialize the servlet lazily.
addServlet
in interface ServletContext
servletName
- the name of the servletdescription
- the description of the servletclassName
- the fully qualified class name of the servletinitParameters
- the initialization parameters of the servlet,
or null if the servlet does not need anyloadOnStartup
- the initialization priority of the servletpublic void addServletMapping(String servletName, String[] urlPatterns)
javax.servlet.ServletContext
The servlet with the given name may have been declared in the
deployment descriptor or one of the web fragments of this servlet
context, or may be added using addServlet
. It is
legal to add a servlet mapping for a servlet that has not yet been
added.
addServletMapping
in interface ServletContext
servletName
- the name of the servlet for which the servlet
mapping is addedurlPatterns
- the url patterns of the servlet mapping
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |