What are the mechanisms available in ServletContextListener interface?

Options
- contextInit(), contextService(), contextDestroyed()
- contextInitialized((),contextDestroyed()
- contextInitialized(), contextService(), contextDestroyed()
- None of the above


CORRECT ANSWER : contextInitialized((),contextDestroyed()

Discussion Board
ServletContextListener

ServletContextListener interface provides a way to receive notifications about changes to the servlet context of the web application they are part of. Deployment descriptor is used to having the configuration set to receive notification events for the web application. It has two methods or mechanisms:

void contextInitialized(ServletContextEvent sce)

It provides the notification for the initialization process of the web application. All ServletContextListeners are notified of context initialization before any filter or servlet in the web application is initialized.

void contextDestroyed(ServletContextEvent sce)

It is the second method that allows to provide the notification that the servlet context is about to be shut down. Servlets and filters that are using this gets destroyed before any ServletContextListeners are notified of context destruction.

Rohit Sharma 11-30-2014 07:17 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement