javax.servlet.ServletContext interface provides access
to web application parameters to the servlet. The ServletContext is
unique object and available to all the servlets in the web application.
When we want some init parameters to be available to multiple or all of
the servlets in the web application, we can use ServletContext object
and define parameters in web.xml using <context-param> element. We
can get the ServletContext object via the getServletContext()
method of ServletConfig. Servlet containers may also provide context
objects that are unique to a group of servlets and which is tied to a
specific portion of the URL path namespace of the host.
ServletContext is enhanced in Servlet Specs 3 to introduce methods
through which we can programmatically add Listeners and Filters and
Servlet to the application. It also provides some utility methods such
as getMimeType(), getResourceAsStream() etc.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
javax.servlet.ServletContextinterface provides access to web application parameters to the servlet. The ServletContext is unique object and available to all the servlets in the web application. When we want some init parameters to be available to multiple or all of the servlets in the web application, we can use ServletContext object and define parameters in web.xml using <context-param> element. We can get the ServletContext object via the getServletContext() method of ServletConfig. Servlet containers may also provide context objects that are unique to a group of servlets and which is tied to a specific portion of the URL path namespace of the host.ServletContext is enhanced in Servlet Specs 3 to introduce methods through which we can programmatically add Listeners and Filters and Servlet to the application. It also provides some utility methods such as getMimeType(), getResourceAsStream() etc.