1. listener
(1) What is the listeners?
Servlet specification among a special assembly defined, used to monitor
events generated by the servlet container and processed.
Events are two major categories:
container create or destroy request, session,: a, life-cycle events related
event occurs when three ServletContext object.
b, bindings related events: call request, session, ServletContext the
setAttribute, removeAttribute event generated.
(2) how to write a listener?
Step1, the first to write a java class that implements the appropriate listener interface.
To listen based on the type of event to select the appropriate listener interface (
for example, to listen for session creation and destruction, to use
HttpSessionListener Interface).
Step2, the method in which the interface declared to achieve corresponding processing logic.
step3, registered listener (web.xml).
Online page
2. ServletContext Interface
(1) of the container when it starts, it creates a unique instance in line with ServletContext interface for each application, called instances ServletContext interface, called Servlet context. Servlet context will always exist,
unless the container is closed or the application is uninstalled.
(2) How to get the ServletContext?
A, GenericServlet.getServ