Index: 3rdParty_sources/servlet-api/javax/servlet/ServletContext.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r188531e2b734df509672788d897e1030e4b1a24a --- 3rdParty_sources/servlet-api/javax/servlet/ServletContext.java (.../ServletContext.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ 3rdParty_sources/servlet-api/javax/servlet/ServletContext.java (.../ServletContext.java) (revision 188531e2b734df509672788d897e1030e4b1a24a) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -70,22 +70,22 @@ /** * Defines a set of methods that a servlet uses to communicate with its - * servlet container, for example, to get the MIME type of a file, dispatch - * requests, or write to a log file. + * servlet container, for example, to get the MIME type of a file, + * dispatch requests, or write to a log file. * *

There is one context per "web application" per Java Virtual Machine. (A * "web application" is a collection of servlets and content installed under a * specific subset of the server's URL namespace such as /catalog - * and possibly installed via a .war file.) + * and possibly installed via a .war file.) * *

In the case of a web * application marked "distributed" in its deployment descriptor, there will - * be one context instance for each virtual machine. In this situation, the + * be one context instance for each virtual machine. In this situation, the * context cannot be used as a location to share global information (because - * the information won't be truly global). Use an external resource like + * the information won't be truly global). Use an external resource like * a database instead. * - *

The ServletContext object is contained within + *

The ServletContext object is contained within * the {@link ServletConfig} object, which the Web server provides the * servlet when the servlet is initialized. * @@ -123,10 +123,10 @@ * *

The context path is the portion of the request URI that is used * to select the context of the request. The context path always comes - * first in a request URI. If this context is the “default” context - * rooted at the base of the Web server’s URL name space, this path + * first in a request URI. If this context is the "root" context + * rooted at the base of the Web server's URL name space, this path * will be an empty string. Otherwise, if the context is not rooted at - * the root of the server’s name space, the path starts with a / + * the root of the server's name space, the path starts with a / * character but does not end with a / character. * *

It is possible that a servlet container may match a context by @@ -138,7 +138,7 @@ * prime or preferred context path of the application. * * @return The context path of the web application, or "" for the - * default (root) context + * root context * * @see javax.servlet.http.HttpServletRequest#getContextPath() * @@ -148,51 +148,51 @@ /** - * Returns a ServletContext object that + * Returns a ServletContext object that * corresponds to a specified URL on the server. * *

This method allows servlets to gain * access to the context for various parts of the server, and as * needed obtain {@link RequestDispatcher} objects from the context. - * The given path must be begin with /, is interpreted relative + * The given path must be begin with /, is interpreted relative * to the server's document root and is matched against the context * roots of other web applications hosted on this container. - * + * *

In a security conscious environment, the servlet container may * return null for a given URL. - * + * * @param uripath a String specifying the context path of * another web application in the container. * @return the ServletContext object that * corresponds to the named URL, or null if either - none exists or the container wishes to restrict + none exists or the container wishes to restrict * this access. * * @see RequestDispatcher */ public ServletContext getContext(String uripath); - + /** * Returns the major version of the Servlet API that this * servlet container supports. All implementations that comply - * with Version 3.0 must have this method return the integer 3. + * with Version 4.0 must have this method return the integer 4. * - * @return 3 + * @return 4 */ public int getMajorVersion(); - - + + /** * Returns the minor version of the Servlet API that this * servlet container supports. All implementations that comply - * with Version 3.0 must have this method return the integer 0. + * with Version 4.0 must have this method return the integer 0. * * @return 0 */ public int getMinorVersion(); - - + + /** * Gets the major version of the Servlet specification that the * application represented by this ServletContext is based on. @@ -213,8 +213,8 @@ * @since Servlet 3.0 */ public int getEffectiveMajorVersion(); - - + + /** * Gets the minor version of the Servlet specification that the * application represented by this ServletContext is based on. @@ -224,7 +224,7 @@ * supported by the Servlet container. * * @return the minor version of the Servlet specification that the - * application xrepresented by this ServletContext is based on + * application represented by this ServletContext is based on * * @throws UnsupportedOperationException if this ServletContext was * passed to the {@link ServletContextListener#contextInitialized} method @@ -238,7 +238,7 @@ /** - * Returns the MIME type of the specified file, or null if + * Returns the MIME type of the specified file, or null if * the MIME type is not known. The MIME type is determined * by the configuration of the servlet container, and may be specified * in a web application deployment descriptor. Common MIME @@ -249,8 +249,8 @@ * @return a String specifying the file's MIME type */ public String getMimeType(String file); - + /** * Returns a directory-like listing of all the paths to resources * within the web application whose longest sub-path matches the @@ -263,9 +263,13 @@ * directory of a JAR file inside the web application's * /WEB-INF/lib directory, and have a leading /. * + *

The returned set is not backed by the {@code ServletContext} object, + * so changes in the returned set are not reflected in the + * {@code ServletContext} object, and vice-versa.

+ * *

For example, for a web application containing: * - *

+     * 
{@code
      *   /welcome.html
      *   /catalog/index.html
      *   /catalog/products.html
@@ -275,25 +279,25 @@
      *   /WEB-INF/web.xml
      *   /WEB-INF/classes/com.acme.OrderServlet.class
      *   /WEB-INF/lib/catalog.jar!/META-INF/resources/catalog/moreOffers/books.html
-     * 
- * + * }
+ * * getResourcePaths("/") would return * {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}, * and getResourcePaths("/catalog/") would return * {"/catalog/index.html", "/catalog/products.html", * "/catalog/offers/", "/catalog/moreOffers/"}. - * + * * @param path the partial path used to match the resources, * which must start with a / * @return a Set containing the directory listing, or null if there * are no resources in the web application whose path * begins with the supplied path. - * + * * @since Servlet 2.3 - */ + */ public Set getResourcePaths(String path); - + /** * Returns a URL to the resource that is mapped to the given path. * @@ -308,10 +312,10 @@ * The order in which the JAR files inside /WEB-INF/lib * are searched is undefined. * - *

This method allows the servlet container to make a resource - * available to servlets from any source. Resources + *

This method allows the servlet container to make a resource + * available to servlets from any source. Resources * can be located on a local or remote - * file system, in a database, or in a .war file. + * file system, in a database, or in a .war file. * *

The servlet container must implement the URL handlers * and URLConnection objects that are necessary @@ -323,38 +327,38 @@ *

Some containers may allow writing to the URL returned by * this method using the methods of the URL class. * - *

The resource content is returned directly, so be aware that + *

The resource content is returned directly, so be aware that * requesting a .jsp page returns the JSP source code. - * Use a RequestDispatcher instead to include results of + * Use a RequestDispatcher instead to include results of * an execution. * *

This method has a different purpose than * java.lang.Class.getResource, * which looks up resources based on a class loader. This * method does not use class loaders. - * + * * @param path a String specifying * the path to the resource * * @return the resource located at the named path, * or null if there is no resource at that path * - * @exception MalformedURLException if the pathname is not given in + * @exception MalformedURLException if the pathname is not given in * the correct form - */ + */ public URL getResource(String path) throws MalformedURLException; - + /** * Returns the resource located at the named path as * an InputStream object. * - *

The data in the InputStream can be + *

The data in the InputStream can be * of any type or length. The path must be specified according * to the rules given in getResource. * This method returns null if no resource exists at - * the specified path. - * + * the specified path. + * *

Meta-information such as content length and content type * that is available via getResource * method is lost when using this method. @@ -363,28 +367,28 @@ * and URLConnection objects necessary to access * the resource. * - *

This method is different from + *

This method is different from * java.lang.Class.getResourceAsStream, - * which uses a class loader. This method allows servlet containers + * which uses a class loader. This method allows servlet containers * to make a resource available * to a servlet from any location, without using a class loader. - * * + * * @param path a String specifying the path * to the resource * - * @return the InputStream returned to the + * @return the InputStream returned to the * servlet, or null if no resource - * exists at the specified path + * exists at the specified path */ public InputStream getResourceAsStream(String path); - + /** - * + * * Returns a {@link RequestDispatcher} object that acts * as a wrapper for the resource located at the given path. - * A RequestDispatcher object can be used to forward + * A RequestDispatcher object can be used to forward * a request to the resource or to include the resource in a response. * The resource can be dynamic or static. * @@ -402,7 +406,7 @@ * * @return a RequestDispatcher object * that acts as a wrapper for the resource - * at the specified path, or null if + * at the specified path, or null if * the ServletContext cannot return * a RequestDispatcher * @@ -416,12 +420,12 @@ * Returns a {@link RequestDispatcher} object that acts * as a wrapper for the named servlet. * - *

Servlets (and JSP pages also) may be given names via server + *

Servlets (and JSP pages also) may be given names via server * administration or via a web application deployment descriptor. - * A servlet instance can determine its name using + * A servlet instance can determine its name using * {@link ServletConfig#getServletName}. * - *

This method returns null if the + *

This method returns null if the * ServletContext * cannot return a RequestDispatcher for any reason. * @@ -438,24 +442,30 @@ * @see ServletConfig#getServletName */ public RequestDispatcher getNamedDispatcher(String name); - - + + /** * @deprecated As of Java Servlet API 2.1, with no direct replacement. * *

This method was originally defined to retrieve a servlet - * from a ServletContext. In this version, this method - * always returns null and remains only to preserve - * binary compatibility. This method will be permanently removed + * from a ServletContext. In this version, this method + * always returns null and remains only to preserve + * binary compatibility. This method will be permanently removed * in a future version of the Java Servlet API. * - *

In lieu of this method, servlets can share information using the + *

In lieu of this method, servlets can share information using the * ServletContext class and can perform shared business logic * by invoking methods on common non-servlet classes. + * + * @param name the servlet name + * @return the {@code javax.servlet.Servlet Servlet} with the given name + * @throws ServletException if an exception has occurred that interfaces + * with servlet's normal operation */ + @Deprecated public Servlet getServlet(String name) throws ServletException; - + /** * @deprecated As of Java Servlet API 2.0, with no replacement. * @@ -466,62 +476,72 @@ * remains only to preserve binary compatibility. This method * will be permanently removed in a future version of the Java * Servlet API. + * + * @return an Enumeration of {@code javax.servlet.Servlet Servlet} */ + @Deprecated public Enumeration getServlets(); - + /** * @deprecated As of Java Servlet API 2.1, with no replacement. * - *

This method was originally defined to return an + *

This method was originally defined to return an * Enumeration * of all the servlet names known to this context. In this version, - * this method always returns an empty Enumeration and - * remains only to preserve binary compatibility. This method will + * this method always returns an empty Enumeration and + * remains only to preserve binary compatibility. This method will * be permanently removed in a future version of the Java Servlet API. + * + * @return an Enumeration of {@code javax.servlet.Servlet Servlet} names */ + @Deprecated public Enumeration getServletNames(); - + /** * * Writes the specified message to a servlet log file, usually - * an event log. The name and type of the servlet log file is + * an event log. The name and type of the servlet log file is * specific to the servlet container. * - * @param msg a String specifying the + * @param msg a String specifying the * message to be written to the log file */ public void log(String msg); - + /** * @deprecated As of Java Servlet API 2.1, use - * {@link #log(String message, Throwable throwable)} + * {@link #log(String message, Throwable throwable)} * instead. * - *

This method was originally defined to write an + *

This method was originally defined to write an * exception's stack trace and an explanatory error message * to the servlet log file. + * + * @param exception the Exception error + * @param msg a String that describes the exception */ + @Deprecated public void log(Exception exception, String msg); - + /** * Writes an explanatory message and a stack trace * for a given Throwable exception - * to the servlet log file. The name and type of the servlet log + * to the servlet log file. The name and type of the servlet log * file is specific to the servlet container, usually an event log. * - * @param message a String that + * @param message a String that * describes the error or exception * - * @param throwable the Throwable error + * @param throwable the Throwable error * or exception */ public void log(String message, Throwable throwable); - - + + /** * Gets the real path corresponding to the given * virtual path. @@ -555,44 +575,48 @@ * translation cannot be performed */ public String getRealPath(String path); - + /** * Returns the name and version of the servlet container on which - * the servlet is running. + * the servlet is running. * - *

The form of the returned string is + *

The form of the returned string is * servername/versionnumber. * For example, the JavaServer Web Development Kit may return the string * JavaServer Web Dev Kit/1.0. * - *

The servlet container may return other optional information + *

The servlet container may return other optional information * after the primary string in parentheses, for example, * JavaServer Web Dev Kit/1.0 (JDK 1.1.6; Windows NT 4.0 x86). * * - * @return a String containing at least the + * @return a String containing at least the * servlet container name and version number */ public String getServerInfo(); - + /** * Returns a String containing the value of the named - * context-wide initialization parameter, or null if the - * parameter does not exist. + * context-wide initialization parameter, or null if + * the parameter does not exist. * *

This method can make available configuration information useful - * to an entire web application. For example, it can provide a - * webmaster's email address or the name of a system that holds + * to an entire web application. For example, it can provide a + * webmaster's email address or the name of a system that holds * critical data. * * @param name a String containing the name of the * parameter whose value is requested - * - * @return a String containing at least the - * servlet container name and version number * + * @return a String containing the value of the + * context's initialization parameter, or null if the + * context's initialization parameter does not exist. + * + * @throws NullPointerException if the argument {@code name} is + * {@code null} + * * @see ServletConfig#getInitParameter */ public String getInitParameter(String name); @@ -604,15 +628,15 @@ * empty Enumeration if the context has no initialization * parameters. * - * @return an Enumeration of String + * @return an Enumeration of String * objects containing the names of the context's * initialization parameters * * @see ServletConfig#getInitParameter */ public Enumeration getInitParameterNames(); - + /** * Sets the context initialization parameter with the given name and * value on this ServletContext. @@ -628,20 +652,22 @@ * @throws IllegalStateException if this ServletContext has already * been initialized * + * @throws NullPointerException if the name parameter is {@code null} + * * @throws UnsupportedOperationException if this ServletContext was * passed to the {@link ServletContextListener#contextInitialized} method * of a {@link ServletContextListener} that was neither declared in * web.xml or web-fragment.xml, nor annotated * with {@link javax.servlet.annotation.WebListener} - * + * * @since Servlet 3.0 */ public boolean setInitParameter(String name, String value); /** - * Returns the servlet container attribute with the given name, - * or null if there is no attribute by that name. + * Returns the servlet container attribute with the given name, or + * null if there is no attribute by that name. * *

An attribute allows a servlet container to give the * servlet additional information not @@ -658,81 +684,87 @@ * matching java.*, javax.*, * and sun.*. * - * @param name a String specifying the name + * @param name a String specifying the name * of the attribute * - * @return an Object containing the value - * of the attribute, or null - * if no attribute exists matching the given - * name + * @return an Object containing the value of the + * attribute, or null if no attribute + * exists matching the given name. * * @see ServletContext#getAttributeNames + * + * @throws NullPointerException if the argument {@code name} is + * {@code null} + * */ public Object getAttribute(String name); - + /** - * Returns an Enumeration containing the + * Returns an Enumeration containing the * attribute names available within this ServletContext. * *

Use the {@link #getAttribute} method with an attribute name * to get the value of an attribute. * - * @return an Enumeration of attribute + * @return an Enumeration of attribute * names * * @see #getAttribute */ public Enumeration getAttributeNames(); - - + + /** * Binds an object to a given attribute name in this ServletContext. If * the name specified is already used for an attribute, this * method will replace the attribute with the new to the new attribute. - *

If listeners are configured on the ServletContext the + *

If listeners are configured on the ServletContext the * container notifies them accordingly. *

- * If a null value is passed, the effect is the same as calling + * If a null value is passed, the effect is the same as calling * removeAttribute(). - * + * *

Attribute names should follow the same convention as package * names. The Java Servlet API specification reserves names * matching java.*, javax.*, and * sun.*. * - * @param name a String specifying the name + * @param name a String specifying the name * of the attribute * * @param object an Object representing the * attribute to be bound + * + * @throws NullPointerException if the name parameter is {@code null} + * */ public void setAttribute(String name, Object object); - + /** - * Removes the attribute with the given name from + * Removes the attribute with the given name from * this ServletContext. After removal, subsequent calls to * {@link #getAttribute} to retrieve the attribute's value * will return null. * - *

If listeners are configured on the ServletContext the + *

If listeners are configured on the ServletContext the * container notifies them accordingly. * - * @param name a String specifying the name + * @param name a String specifying the name * of the attribute to be removed */ public void removeAttribute(String name); - + /** * Returns the name of this web application corresponding to this * ServletContext as specified in the deployment descriptor for this * web application by the display-name element. * * @return The name of the web application or null if no name has been * declared in the deployment descriptor. - * + * * @since Servlet 2.3 */ public String getServletContextName(); @@ -745,7 +777,7 @@ *

The registered servlet may be further configured via the returned * {@link ServletRegistration} object. * - *

The specified className will be loaded using the + *

The specified className will be loaded using the * classloader associated with the application represented by this * ServletContext. * @@ -755,7 +787,7 @@ * and returned. * *

This method introspects the class with the given className - * for the {@link javax.servlet.annotation.ServletSecurity}, + * for the {@link javax.servlet.annotation.ServletSecurity}, * {@link javax.servlet.annotation.MultipartConfig}, * javax.annotation.security.RunAs, and * javax.annotation.security.DeclareRoles annotations. @@ -770,7 +802,7 @@ * @return a ServletRegistration object that may be used to further * configure the registered servlet, or null if this * ServletContext already contains a complete ServletRegistration for - * a servlet with the given servletName + * a servlet with the given servletName * * @throws IllegalStateException if this ServletContext has already * been initialized @@ -821,7 +853,7 @@ * web.xml or web-fragment.xml, nor annotated * with {@link javax.servlet.annotation.WebListener} * - * @throws IllegalArgumentException if the given servlet instance + * @throws IllegalArgumentException if the given servlet instance * implements {@link SingleThreadModel}, or servletName is null * or an empty String * @@ -844,7 +876,7 @@ * servletClass to it) and returned. * *

This method introspects the given servletClass for - * the {@link javax.servlet.annotation.ServletSecurity}, + * the {@link javax.servlet.annotation.ServletSecurity}, * {@link javax.servlet.annotation.MultipartConfig}, * javax.annotation.security.RunAs, and * javax.annotation.security.DeclareRoles annotations. @@ -860,7 +892,7 @@ * @return a ServletRegistration object that may be used to further * configure the registered servlet, or null if this * ServletContext already contains a complete ServletRegistration for - * the given servletName + * the given servletName * * @throws IllegalStateException if this ServletContext has already * been initialized @@ -881,18 +913,56 @@ /** + * Adds the servlet with the given jsp file to this servlet context. + * + *

The registered servlet may be further configured via the returned + * {@link ServletRegistration} object. + * + *

If this ServletContext already contains a preliminary + * ServletRegistration for a servlet with the given servletName, + * it will be completed (by assigning the given jspFile to it) + * and returned. + * + * @param servletName the name of the servlet + * @param jspFile the full path to a JSP file within the web application + * beginning with a `/'. + * + * @return a ServletRegistration object that may be used to further + * configure the registered servlet, or null if this + * ServletContext already contains a complete ServletRegistration for + * a servlet with the given servletName + * + * @throws IllegalStateException if this ServletContext has already + * been initialized + * + * @throws IllegalArgumentException if servletName is null + * or an empty String + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public ServletRegistration.Dynamic addJspFile( + String servletName, String jspFile); + + + /** * Instantiates the given Servlet class. * *

The returned Servlet instance may be further customized before it - * is registered with this ServletContext via a call to + * is registered with this ServletContext via a call to * {@link #addServlet(String,Servlet)}. * *

The given Servlet class must define a zero argument constructor, * which is used to instantiate it. * *

This method introspects the given clazz for * the following annotations: - * {@link javax.servlet.annotation.ServletSecurity}, + * {@link javax.servlet.annotation.ServletSecurity}, * {@link javax.servlet.annotation.MultipartConfig}, * javax.annotation.security.RunAs, and * javax.annotation.security.DeclareRoles. @@ -901,6 +971,7 @@ * See the Java EE platform and JSR 299 specifications for additional * details about Managed Beans and resource injection. * + * @param the class of the Servlet to create * @param clazz the Servlet class to instantiate * * @return the new Servlet instance @@ -919,6 +990,7 @@ public T createServlet(Class clazz) throws ServletException; + /** * Gets the ServletRegistration corresponding to the servlet with the * given servletName. @@ -933,6 +1005,7 @@ * web.xml or web-fragment.xml, nor annotated * with {@link javax.servlet.annotation.WebListener} * + * @param servletName the name of a servlet * @since Servlet 3.0 */ public ServletRegistration getServletRegistration(String servletName); @@ -946,7 +1019,8 @@ *

The returned Map includes the ServletRegistration objects * corresponding to all declared and annotated servlets, as well as the * ServletRegistration objects corresponding to all servlets that have - * been added via one of the addServlet methods. + * been added via one of the addServlet and addJspFile + * methods. * *

If permitted, any changes to the returned Map must not affect this * ServletContext. @@ -973,7 +1047,7 @@ *

The registered filter may be further configured via the returned * {@link FilterRegistration} object. * - *

The specified className will be loaded using the + *

The specified className will be loaded using the * classloader associated with the application represented by this * ServletContext. * @@ -993,7 +1067,7 @@ * @return a FilterRegistration object that may be used to further * configure the registered filter, or null if this * ServletContext already contains a complete FilterRegistration for - * a filter with the given filterName + * a filter with the given filterName * * @throws IllegalStateException if this ServletContext has already * been initialized @@ -1011,8 +1085,8 @@ */ public FilterRegistration.Dynamic addFilter( String filterName, String className); - + /** * Registers the given filter instance with this ServletContext * under the given filterName. @@ -1077,7 +1151,7 @@ * @return a FilterRegistration object that may be used to further * configure the registered filter, or null if this * ServletContext already contains a complete FilterRegistration for a - * filter with the given filterName + * filter with the given filterName * * @throws IllegalStateException if this ServletContext has already * been initialized @@ -1101,7 +1175,7 @@ * Instantiates the given Filter class. * *

The returned Filter instance may be further customized before it - * is registered with this ServletContext via a call to + * is registered with this ServletContext via a call to * {@link #addFilter(String,Filter)}. * *

The given Filter class must define a zero argument constructor, @@ -1112,6 +1186,7 @@ * See the Java EE platform and JSR 299 specifications for additional * details about Managed Beans and resource injection. * + * @param the class of the Filter to create * @param clazz the Filter class to instantiate * * @return the new Filter instance @@ -1135,6 +1210,7 @@ * Gets the FilterRegistration corresponding to the filter with the * given filterName. * + * @param filterName the name of a filter * @return the (complete or preliminary) FilterRegistration for the * filter with the given filterName, or null if no * FilterRegistration exists under that name @@ -1236,6 +1312,10 @@ * Gets the session tracking modes that are supported by default for this * ServletContext. * + *

The returned set is not backed by the {@code ServletContext} object, + * so changes in the returned set are not reflected in the + * {@code ServletContext} object, and vice-versa.

+ * * @return set of the session tracking modes supported by default for * this ServletContext * @@ -1257,9 +1337,9 @@ *

The session tracking modes in effect are those provided to * {@link #setSessionTrackingModes setSessionTrackingModes}. * - *

By default, the session tracking modes returned by - * {@link #getDefaultSessionTrackingModes getDefaultSessionTrackingModes} - * are in effect. + *

The returned set is not backed by the {@code ServletContext} object, + * so changes in the returned set are not reflected in the + * {@code ServletContext} object, and vice-versa.

* * @return set of the session tracking modes in effect for this * ServletContext @@ -1283,21 +1363,21 @@ * ServletContext, and must implement one or more of the following * interfaces: * * - *

If this ServletContext was passed to + *

If this ServletContext was passed to * {@link ServletContainerInitializer#onStartup}, then the class with * the given name may also implement {@link ServletContextListener}, * in addition to the interfaces listed above. * *

As part of this method call, the container must load the class - * with the specified class name to ensure that it implements one of + * with the specified class name to ensure that it implements one of * the required interfaces. * *

If the class with the given name implements a listener interface @@ -1340,15 +1420,15 @@ *

The given listener must be an instance of one or more of the * following interfaces: *

* - *

If this ServletContext was passed to + *

If this ServletContext was passed to * {@link ServletContainerInitializer#onStartup}, then the given * listener may also be an instance of {@link ServletContextListener}, * in addition to the interfaces listed above. @@ -1361,6 +1441,7 @@ * then the listener will be added to the end of the ordered list of * listeners of that interface. * + * @param the class of the EventListener to add * @param t the listener to be added * * @throws IllegalArgumentException if the given listener is not @@ -1388,15 +1469,15 @@ *

The given listenerClass must implement one or more of the * following interfaces: *

* - *

If this ServletContext was passed to + *

If this ServletContext was passed to * {@link ServletContainerInitializer#onStartup}, then the given * listenerClass may also implement * {@link ServletContextListener}, in addition to the interfaces listed @@ -1440,13 +1521,13 @@ * Instantiates the given EventListener class. * *

The specified EventListener class must implement at least one of - * the {@link ServletContextListener}, - * {@link ServletContextAttributeListener}, - * {@link ServletRequestListener}, - * {@link ServletRequestAttributeListener}, - * {@link javax.servlet.http.HttpSessionAttributeListener} - * {@link javax.servlet.http.HttpSessionIdListener}, or - * {@link javax.servlet.http.HttpSessionListener}, or + * the {@link ServletContextListener}, + * {@link ServletContextAttributeListener}, + * {@link ServletRequestListener}, + * {@link ServletRequestAttributeListener}, + * {@link javax.servlet.http.HttpSessionAttributeListener}, + * {@link javax.servlet.http.HttpSessionIdListener}, or + * {@link javax.servlet.http.HttpSessionListener} * interfaces. * *

The returned EventListener instance may be further customized @@ -1461,6 +1542,7 @@ * See the Java EE platform and JSR 299 specifications for additional * details about Managed Beans and resource injection. * + * @param the class of the EventListener to create * @param clazz the EventListener class to instantiate * * @return the new EventListener instance @@ -1476,19 +1558,19 @@ * * @throws IllegalArgumentException if the specified EventListener class * does not implement any of the - * {@link ServletContextListener}, - * {@link ServletContextAttributeListener}, - * {@link ServletRequestListener}, - * {@link ServletRequestAttributeListener}, - * {@link javax.servlet.http.HttpSessionAttributeListener} - * {@link javax.servlet.http.HttpSessionIdListener}, or - * {@link javax.servlet.http.HttpSessionListener}, or + * {@link ServletContextListener}, + * {@link ServletContextAttributeListener}, + * {@link ServletRequestListener}, + * {@link ServletRequestAttributeListener}, + * {@link javax.servlet.http.HttpSessionAttributeListener}, + * {@link javax.servlet.http.HttpSessionIdListener}, or + * {@link javax.servlet.http.HttpSessionListener} * interfaces. * * @since Servlet 3.0 */ public T createListener(Class clazz) - throws ServletException; + throws ServletException; /** @@ -1536,7 +1618,7 @@ * web.xml or web-fragment.xml, nor annotated * with {@link javax.servlet.annotation.WebListener} * - * @throws SecurityException if a security manager denies access to + * @throws SecurityException if a security manager denies access to * the requested class loader * * @since Servlet 3.0 @@ -1596,4 +1678,121 @@ * @since Servlet 3.1 */ public String getVirtualServerName(); + + + /** + * Gets the session timeout in minutes that are supported by default for + * this ServletContext. + * + * @return the session timeout in minutes that are supported by default for + * this ServletContext + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public int getSessionTimeout(); + + + /** + * Sets the session timeout in minutes for this ServletContext. + * + * @param sessionTimeout session timeout in minutes + * + * @throws IllegalStateException if this ServletContext has already + * been initialized + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public void setSessionTimeout(int sessionTimeout); + + + /** + * Gets the request character encoding that are supported by default for + * this ServletContext. This method returns null if no request + * encoding character encoding has been specified in deployment descriptor + * or container specific configuration (for all web applications in the + * container). + * + * @return the request character encoding that are supported by default for + * this ServletContext + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public String getRequestCharacterEncoding(); + + + /** + * Sets the request character encoding for this ServletContext. + * + * @param encoding request character encoding + * + * @throws IllegalStateException if this ServletContext has already + * been initialized + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public void setRequestCharacterEncoding(String encoding); + + + /** + * Gets the response character encoding that are supported by default for + * this ServletContext. This method returns null if no response + * encoding character encoding has been specified in deployment descriptor + * or container specific configuration (for all web applications in the + * container). + * + * @return the request character encoding that are supported by default for + * this ServletContext + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public String getResponseCharacterEncoding(); + + + /** + * Sets the response character encoding for this ServletContext. + * + * @param encoding response character encoding + * + * @throws IllegalStateException if this ServletContext has already + * been initialized + * + * @throws UnsupportedOperationException if this ServletContext was + * passed to the {@link ServletContextListener#contextInitialized} method + * of a {@link ServletContextListener} that was neither declared in + * web.xml or web-fragment.xml, nor annotated + * with {@link javax.servlet.annotation.WebListener} + * + * @since Servlet 4.0 + */ + public void setResponseCharacterEncoding(String encoding); }