Package org.apache.jasper.servlet
Class JspCServletContext
java.lang.Object
org.apache.jasper.servlet.JspCServletContext
- All Implemented Interfaces:
- ServletContext
Simple 
ServletContext implementation without
 HTTP-specific methods.- Author:
- Peter Rossbach (pr@webapp.de)
- 
Field SummaryFields inherited from interface jakarta.servlet.ServletContextORDERED_LIBS, TEMPDIR
- 
Constructor SummaryConstructorsConstructorDescriptionJspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL, ClassLoader classLoader, boolean validate, boolean blockExternal) Create a new instance of this ServletContext implementation.
- 
Method SummaryModifier and TypeMethodDescriptionAdd filter to context.Add filter to context.Add filter to context.addJspFile(String jspName, String jspFile) Add a JSP to the context.voidaddListener(Class<? extends EventListener> listenerClass) TODO SERVLET3 - Add commentsvoidaddListener(String className) TODO SERVLET3 - Add comments<T extends EventListener>
 voidaddListener(T t) TODO SERVLET3 - Add commentsaddServlet(String servletName, Servlet servlet) Register a servlet instance for use in this ServletContext.addServlet(String servletName, Class<? extends Servlet> servletClass) Add servlet to the context.addServlet(String servletName, String className) Register a servlet implementation for use in this ServletContext.<T extends Filter>
 TcreateFilter(Class<T> c) Create a Filter instance using the given class.<T extends EventListener>
 TcreateListener(Class<T> c) TODO SERVLET3 - Add comments<T extends Servlet>
 TcreateServlet(Class<T> c) Create an Servlet instance using the given class.voiddeclareRoles(String... roleNames) Add to the declared roles for this ServletContext.getAttribute(String name) Return the specified context attribute, if any.Return an enumeration of context attribute names.Get the web application class loader associated with this ServletContext.getContext(String uripath) Return the servlet context for the specified path.Return the context path.Obtains the default session tracking modes for this web application.intObtain the major version of the servlet specification for which this web application is implemented.intObtain the minor version of the servlet specification for which this web application is implemented.Obtains the currently enabled session tracking modes for this web application.getFilterRegistration(String filterName) TODO SERVLET3 - Add commentsMap<String,? extends FilterRegistration> getInitParameter(String name) Return the specified context initialization parameter.Return an enumeration of the names of context initialization parameters.intReturn the Servlet API major version number.getMimeType(String file) Return the MIME type for the specified filename.intReturn the Servlet API minor version number.getNamedDispatcher(String name) Return a request dispatcher for the specified servlet name.getRealPath(String path) Return the real path for the specified context-relative virtual path.Get the default character encoding for reading request bodies.getRequestDispatcher(String path) Return a request dispatcher for the specified context-relative path.getResource(String path) Return a URL object of a resource that is mapped to the specified context-relative path.getResourceAsStream(String path) Return an InputStream allowing access to the resource at the specified context-relative path.getResourcePaths(String path) Return the set of resource paths for the "directory" at the specified context path.Get the default character encoding for writing response bodies.Return descriptive information about this server.Return the name of this servlet context.getServletRegistration(String servletName) Obtain the details of the named servlet.Map<String,? extends ServletRegistration> Obtain a Map of servlet names to servlet registrations for all servlets registered with this context.intGet the default session timeout.Get the primary name of the virtual host on which this context is deployed.voidLog the specified message.voidLog 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.booleansetInitParameter(String name, String value) Set the given initialisation parameter to the given value.voidsetRequestCharacterEncoding(String encoding) Set the default character encoding to use for reading request bodies.voidsetResponseCharacterEncoding(String encoding) Set the default character encoding to use for writing response bodies.voidsetSessionTimeout(int sessionTimeout) Set the default session timeout.voidsetSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) Configures the available session tracking modes for this web application.
- 
Constructor Details- 
JspCServletContextpublic JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL, ClassLoader classLoader, boolean validate, boolean blockExternal) throws JasperException Create a new instance of this ServletContext implementation.- Parameters:
- aLogWriter- PrintWriter which is used for- log()calls
- aResourceBaseURL- Resource base URL
- classLoader- Class loader for this- ServletContext
- validate- Should a validating parser be used to parse web.xml?
- blockExternal- Should external entities be blocked when parsing web.xml?
- Throws:
- JasperException- An error occurred building the merged web.xml
 
 
- 
- 
Method Details- 
getAttributeReturn the specified context attribute, if any.- Specified by:
- getAttributein interface- ServletContext
- Parameters:
- name- Name of the requested attribute
- Returns:
- an Objectcontaining the value of the attribute, ornullif no attribute exists matching the given name
- See Also:
 
- 
getAttributeNamesReturn an enumeration of context attribute names.- Specified by:
- getAttributeNamesin interface- ServletContext
- Returns:
- an Enumerationof attribute names
- See Also:
 
- 
getContextReturn the servlet context for the specified path.- Specified by:
- getContextin interface- ServletContext
- Parameters:
- uripath- Server-relative path starting with '/'
- Returns:
- the ServletContextobject that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access.
- See Also:
 
- 
getContextPathReturn the context path.- Specified by:
- getContextPathin interface- ServletContext
- Returns:
- The main context path
 
- 
getInitParameterReturn the specified context initialization parameter.- Specified by:
- getInitParameterin interface- ServletContext
- Parameters:
- name- Name of the requested parameter
- Returns:
- a Stringcontaining the value of the initialization parameter
- See Also:
 
- 
getInitParameterNamesReturn an enumeration of the names of context initialization parameters.- Specified by:
- getInitParameterNamesin interface- ServletContext
- Returns:
- an EnumerationofStringobjects containing the names of the context's initialization parameters
- See Also:
 
- 
getMajorVersionpublic int getMajorVersion()Return the Servlet API major version number.- Specified by:
- getMajorVersionin interface- ServletContext
- Returns:
- 6
 
- 
getMimeTypeReturn the MIME type for the specified filename.- Specified by:
- getMimeTypein interface- ServletContext
- Parameters:
- file- Filename whose MIME type is requested
- Returns:
- a Stringspecifying the file's MIME type
 
- 
getMinorVersionpublic int getMinorVersion()Return the Servlet API minor version number.- Specified by:
- getMinorVersionin interface- ServletContext
- Returns:
- 0
 
- 
getNamedDispatcherReturn a request dispatcher for the specified servlet name.- Specified by:
- getNamedDispatcherin interface- ServletContext
- Parameters:
- name- Name of the requested servlet
- Returns:
- a RequestDispatcherobject that acts as a wrapper for the named servlet, ornullif theServletContextcannot return aRequestDispatcher
- See Also:
 
- 
getRealPathReturn the real path for the specified context-relative virtual path.- Specified by:
- getRealPathin interface- ServletContext
- Parameters:
- path- The context-relative virtual path to resolve
- Returns:
- a Stringspecifying the real path, or null if the translation cannot be performed
 
- 
getRequestDispatcherReturn a request dispatcher for the specified context-relative path.- Specified by:
- getRequestDispatcherin interface- ServletContext
- Parameters:
- path- Context-relative path for which to acquire a dispatcher
- Returns:
- a RequestDispatcherobject that acts as a wrapper for the resource at the specified path, ornullif theServletContextcannot return aRequestDispatcher
- See Also:
 
- 
getResourceReturn a URL object of a resource that is mapped to the specified context-relative path.- Specified by:
- getResourcein interface- ServletContext
- Parameters:
- path- Context-relative path of the desired resource
- Returns:
- the resource located at the named path, or nullif there is no resource at that path
- Throws:
- MalformedURLException- if the resource path is not properly formed
 
- 
getResourceAsStreamReturn an InputStream allowing access to the resource at the specified context-relative path.- Specified by:
- getResourceAsStreamin interface- ServletContext
- Parameters:
- path- Context-relative path of the desired resource
- Returns:
- the InputStreamreturned to the servlet, ornullif no resource exists at the specified path
 
- 
getResourcePathsReturn the set of resource paths for the "directory" at the specified context path.- Specified by:
- getResourcePathsin interface- ServletContext
- Parameters:
- path- Context-relative base path
- 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.
 
- 
getServerInfoReturn descriptive information about this server.- Specified by:
- getServerInfoin interface- ServletContext
- Returns:
- a Stringcontaining at least the servlet container name and version number
 
- 
getServletContextNameReturn the name of this servlet context.- Specified by:
- getServletContextNamein interface- ServletContext
- Returns:
- The name of the web application or null if no name has been declared in the deployment descriptor.
 
- 
logLog the specified message.- Specified by:
- login interface- ServletContext
- Parameters:
- message- The message to be logged
 
- 
logLog the specified message and exception.- Specified by:
- login interface- ServletContext
- Parameters:
- message- The message to be logged
- exception- The exception to be logged
 
- 
removeAttributeRemove the specified context attribute.- Specified by:
- removeAttributein interface- ServletContext
- Parameters:
- name- Name of the attribute to remove
 
- 
setAttributeSet or replace the specified context attribute.- Specified by:
- setAttributein interface- ServletContext
- Parameters:
- name- Name of the context attribute to set
- value- Corresponding attribute value
 
- 
addFilterDescription copied from interface:jakarta.servlet.ServletContextAdd filter to context.- Specified by:
- addFilterin interface- ServletContext
- Parameters:
- filterName- Name of filter to add
- className- Name of filter class
- Returns:
- nullif the filter has already been fully defined, else a- FilterRegistration.Dynamicobject that can be used to further configure the filter
 
- 
addServletDescription copied from interface:jakarta.servlet.ServletContextRegister a servlet implementation for use in this ServletContext.- Specified by:
- addServletin interface- ServletContext
- Parameters:
- servletName- The name of the servlet to register
- className- The implementation class for the servlet
- Returns:
- The registration object that enables further configuration
 
- 
getDefaultSessionTrackingModesDescription copied from interface:jakarta.servlet.ServletContextObtains the default session tracking modes for this web application. By defaultSessionTrackingMode.URLis always supported,SessionTrackingMode.COOKIEis supported unless thecookiesattribute has been set tofalsefor the context andSessionTrackingMode.SSLis supported if at least one of the connectors used by this context has the attributesecureset totrue.- Specified by:
- getDefaultSessionTrackingModesin interface- ServletContext
- Returns:
- The set of default session tracking modes for this web application
 
- 
getEffectiveSessionTrackingModesDescription copied from interface:jakarta.servlet.ServletContextObtains the currently enabled session tracking modes for this web application.- Specified by:
- getEffectiveSessionTrackingModesin interface- ServletContext
- Returns:
- The value supplied via ServletContext.setSessionTrackingModes(Set)if one was previously set, else return the defaults
 
- 
getSessionCookieConfig- Specified by:
- getSessionCookieConfigin interface- ServletContext
- Returns:
- TODO
 
- 
setSessionTrackingModesDescription copied from interface:jakarta.servlet.ServletContextConfigures the available session tracking modes for this web application.- Specified by:
- setSessionTrackingModesin interface- ServletContext
- Parameters:
- sessionTrackingModes- The session tracking modes to use for this web application
 
- 
addFilterDescription copied from interface:jakarta.servlet.ServletContextAdd filter to context.- Specified by:
- addFilterin interface- ServletContext
- Parameters:
- filterName- Name of filter to add
- filter- Filter to add
- Returns:
- nullif the filter has already been fully defined, else a- FilterRegistration.Dynamicobject that can be used to further configure the filter
 
- 
addFilterDescription copied from interface:jakarta.servlet.ServletContextAdd filter to context.- Specified by:
- addFilterin interface- ServletContext
- Parameters:
- filterName- Name of filter to add
- filterClass- Class of filter to add
- Returns:
- nullif the filter has already been fully defined, else a- FilterRegistration.Dynamicobject that can be used to further configure the filter
 
- 
addServletDescription copied from interface:jakarta.servlet.ServletContextRegister a servlet instance for use in this ServletContext.- Specified by:
- addServletin interface- ServletContext
- Parameters:
- servletName- The name of the servlet to register
- servlet- The Servlet instance to register
- Returns:
- The registration object that enables further configuration
 
- 
addServletpublic ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) Description copied from interface:jakarta.servlet.ServletContextAdd servlet to the context.- Specified by:
- addServletin interface- ServletContext
- Parameters:
- servletName- Name of servlet to add
- servletClass- Class of servlet to add
- Returns:
- nullif the servlet has already been fully defined, else a- ServletRegistration.Dynamicobject that can be used to further configure the servlet
 
- 
addJspFileDescription copied from interface:jakarta.servlet.ServletContextAdd a JSP to the context.- Specified by:
- addJspFilein interface- ServletContext
- Parameters:
- jspName- The servlet name under which this JSP file should be registered
- jspFile- The path, relative to the web application root, for the JSP file to be used for this servlet
- Returns:
- a ServletRegistration.Dynamicobject that can be used to further configure the servlet
 
- 
createFilterDescription copied from interface:jakarta.servlet.ServletContextCreate a Filter instance using the given class. The instance is just created. No initialisation occurs.- Specified by:
- createFilterin interface- ServletContext
- Type Parameters:
- T- The type for the given class
- Parameters:
- c- The the class for which an instance should be created
- Returns:
- The created Filter instance.
- Throws:
- ServletException- If the Filter instance cannot be created
 
- 
createServletDescription copied from interface:jakarta.servlet.ServletContextCreate an Servlet instance using the given class. The instance is just created. No initialisation occurs.- Specified by:
- createServletin interface- ServletContext
- Type Parameters:
- T- The type for the given class
- Parameters:
- c- The the class for which an instance should be created
- Returns:
- The created Servlet instance.
- Throws:
- ServletException- If the servlet instance cannot be created.
 
- 
getFilterRegistrationDescription copied from interface:jakarta.servlet.ServletContextTODO SERVLET3 - Add comments- Specified by:
- getFilterRegistrationin interface- ServletContext
- Parameters:
- filterName- TODO
- Returns:
- TODO
 
- 
getServletRegistrationDescription copied from interface:jakarta.servlet.ServletContextObtain the details of the named servlet.- Specified by:
- getServletRegistrationin interface- ServletContext
- Parameters:
- servletName- The name of the Servlet of interest
- Returns:
- The registration details for the named Servlet or nullif no Servlet has been registered with the given name
 
- 
setInitParameterDescription copied from interface:jakarta.servlet.ServletContextSet the given initialisation parameter to the given value.- Specified by:
- setInitParameterin interface- ServletContext
- Parameters:
- name- Name of initialisation parameter
- value- Value for initialisation parameter
- Returns:
- trueif the call succeeds or- falseif the call fails because an initialisation parameter with the same name has already been set
 
- 
addListenerDescription copied from interface:jakarta.servlet.ServletContextTODO SERVLET3 - Add comments- Specified by:
- addListenerin interface- ServletContext
- Parameters:
- listenerClass- TODO
 
- 
addListenerDescription copied from interface:jakarta.servlet.ServletContextTODO SERVLET3 - Add comments- Specified by:
- addListenerin interface- ServletContext
- Parameters:
- className- TODO
 
- 
addListenerDescription copied from interface:jakarta.servlet.ServletContextTODO SERVLET3 - Add comments- Specified by:
- addListenerin interface- ServletContext
- Type Parameters:
- T- TODO
- Parameters:
- t- TODO
 
- 
createListenerDescription copied from interface:jakarta.servlet.ServletContextTODO SERVLET3 - Add comments- Specified by:
- createListenerin interface- ServletContext
- Type Parameters:
- T- TODO
- Parameters:
- c- TODO
- Returns:
- TODO
- Throws:
- ServletException- TODO
 
- 
declareRolesDescription copied from interface:jakarta.servlet.ServletContextAdd to the declared roles for this ServletContext.- Specified by:
- declareRolesin interface- ServletContext
- Parameters:
- roleNames- The roles to add
 
- 
getClassLoaderDescription copied from interface:jakarta.servlet.ServletContextGet the web application class loader associated with this ServletContext.- Specified by:
- getClassLoaderin interface- ServletContext
- Returns:
- The associated web application class loader
 
- 
getEffectiveMajorVersionpublic int getEffectiveMajorVersion()Description copied from interface:jakarta.servlet.ServletContextObtain the major version of the servlet specification for which this web application is implemented.- Specified by:
- getEffectiveMajorVersionin interface- ServletContext
- Returns:
- The major version declared in web.xml
 
- 
getEffectiveMinorVersionpublic int getEffectiveMinorVersion()Description copied from interface:jakarta.servlet.ServletContextObtain the minor version of the servlet specification for which this web application is implemented.- Specified by:
- getEffectiveMinorVersionin interface- ServletContext
- Returns:
- The minor version declared in web.xml
 
- 
getFilterRegistrations- Specified by:
- getFilterRegistrationsin interface- ServletContext
- Returns:
- TODO
 
- 
getJspConfigDescriptor- Specified by:
- getJspConfigDescriptorin interface- ServletContext
- Returns:
- TODO
 
- 
getServletRegistrationsDescription copied from interface:jakarta.servlet.ServletContextObtain a Map of servlet names to servlet registrations for all servlets registered with this context.- Specified by:
- getServletRegistrationsin interface- ServletContext
- Returns:
- A Map of servlet names to servlet registrations for all servlets registered with this context
 
- 
getVirtualServerNameDescription copied from interface:jakarta.servlet.ServletContextGet the primary name of the virtual host on which this context is deployed. The name may or may not be a valid host name.- Specified by:
- getVirtualServerNamein interface- ServletContext
- Returns:
- The primary name of the virtual host on which this context is deployed
 
- 
getSessionTimeoutpublic int getSessionTimeout()Description copied from interface:jakarta.servlet.ServletContextGet the default session timeout.- Specified by:
- getSessionTimeoutin interface- ServletContext
- Returns:
- The current default session timeout in minutes
 
- 
setSessionTimeoutpublic void setSessionTimeout(int sessionTimeout) Description copied from interface:jakarta.servlet.ServletContextSet the default session timeout. This method may only be called before the ServletContext is initialised.- Specified by:
- setSessionTimeoutin interface- ServletContext
- Parameters:
- sessionTimeout- The new default session timeout in minutes.
 
- 
getRequestCharacterEncodingDescription copied from interface:jakarta.servlet.ServletContextGet the default character encoding for reading request bodies.- Specified by:
- getRequestCharacterEncodingin interface- ServletContext
- Returns:
- The character encoding name or nullif no default has been specified
 
- 
setRequestCharacterEncodingDescription copied from interface:jakarta.servlet.ServletContextSet the default character encoding to use for reading request bodies. Calling this method will over-ride any value set in the deployment descriptor.- Specified by:
- setRequestCharacterEncodingin interface- ServletContext
- Parameters:
- encoding- The name of the character encoding to use
 
- 
getResponseCharacterEncodingDescription copied from interface:jakarta.servlet.ServletContextGet the default character encoding for writing response bodies.- Specified by:
- getResponseCharacterEncodingin interface- ServletContext
- Returns:
- The character encoding name or nullif no default has been specified
 
- 
setResponseCharacterEncodingDescription copied from interface:jakarta.servlet.ServletContextSet the default character encoding to use for writing response bodies. Calling this method will over-ride any value set in the deployment descriptor.- Specified by:
- setResponseCharacterEncodingin interface- ServletContext
- Parameters:
- encoding- The name of the character encoding to use
 
 
-