
Java
Apart from setting and getting custom attributes used for our application, the context also contains various methods that we can use to retrieve specific information about the application and other aspects. They are:
• getAttributeNames() - Returns an Enumeration object containing the attribute names available within this servlet context.
• getContext(String uripath) - Returns a ServletContext object that corresponds to a specified URL on the server.
• getInitParameter(String name) - Returns a string containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.
• getInitParameterNames() - Returns the names of the context's initialization parameters as an Enumeration of string objects, or an empty Enumeration if the context has no initialization parameters.
• getMajorVersion() - Returns the major version as an int of the Java Servlet API that this Servlet Container supports.
• getMimeType(Java.lang.String file) - Returns the MIME type as a string of the specified file, or null if the MIME type is not known.
• getMinorVersion() - Returns the minor version as an int of the Servlet API that this Servlet Container supports.
• getNamedDispatcher(String name) Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
• getRealPath(String path) - Returns a string containing the real path for a given virtual path.
• getRequestDispatcher(String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
• getResource(String path) - Returns a URL to the resource that is mapped to a specified path.
• getResourceAsStream(String path) - Returns the resource located at the named path as an InputStream object.
• getServerInfo() Returns the name and version as a String of the Servlet Container on which the servlet is running.
Copyright © 2026 eLLeNow.com All Rights Reserved.