| Section 3 |
|---|
3.1 Identify the uses for and the interfaces (or classes) and methods to achieve the following features:
|
3.2 Identify the WebApp deployment descriptor element name that declares the following features:
|
3.3 Distinguish the behavior of the following in a distributable:
|
3.1 Identify the uses for and the interfaces (or classes) and methods to achieve the following features:
The ServletContext interface defines a servlet’s view of the web application within
which the servlet is running. The Container Provider is responsible for providing an
implementation of the ServletContext interface in the servlet container. Using the
ServletContext object, a servlet can log events, obtain URL references to
resources, and set and store attributes that other servlets in the context can access.
purpose: defines init parameters accessible by all servlets in the web application
context; settable at deployment-time, but accessible at run-time
purpose: An object that implements the ServletContextListener interface is notified when its web app context is created or destroyed
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
purpose: An object that implements the ServletContextAttributeListener
interface is notified when attributes are added to or removed from its web app
context
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
purpose: An object that implements the HttpSessionAttributeListener interface
is notified when a session attribute is added, removed or replaced
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
purpose: An object that implements the HttpSessionListener interface is notified
when a session is created or destroyed in its web app context
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
purpose: Designed to handle sessions that migrate from one server to another. The listener is notified
when any session is about to passivate(move) and when the session is about to activate(become alive) on
the second host. It gives an app the chance to, for example, persist nonserializable data across jvm's
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
3.2 Identify the WebApp deployment descriptor element name that declares the following features:
<context-param> {param-name, param-value} </context-param>
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
<listener>
<listener-class> {fully qualified class name} </listener-class>
</listener>
3.3 Distinguish the behavior of the following in a distributable:
behavior in a distributable: Consider that a different instance of the ServletContext
may exist on each different JVM and/or machine. Therefore, the context should not be
used to store application state. Any state should be stored externally, e.g. in a database or ejb.
behavior in a distributable:
Each context instance (on different jvm's and/or machines) will have its own instance of the listener object. Therefore, if a context on one jvm/machine is initialized or destroyed, it will not trigger a listener on any other jvm/machine.
behavior in a distributable:
Addition, removal or replacement of an attribute in a context will only affect the listener for that context, and not other context "instances" on other jvm's and/or machines
behavior in a distributable: sessions may migrate from one jvm or machine to another; hence the session unbind event may occur on a different jvm/machine than the session bind event.