Using Event Listeners; Handling Exceptions; Maintaining Page Context Information - MACROMEDIA 38000382 - JRun - Mac Getting Started Manual

Getting started guide
Table of Contents

Advertisement

Using event listeners

One of the major new features of the Java Servlet 2.3 specification is the addition of
servlet event listeners. The specification provides listener classes for web applications.
Also known as event handlers, event listeners provide call-back methods that JRun calls
when certain events occur. Event listeners help you manage disparate elements of the web
application and track state changes in the ServletContext and HttpSession objects.
There are two basic types of servlet event listeners that watch the activity of the
ServletContext and HttpSession objects. Each type has a listener interface and an
attribute listener interface, as the following table shows:
Servlet object
ServletContext
HttpSession
You use event listeners for a number of common tasks, including the following:
For more information on using event listeners, see JRun Programmer's Guide.

Handling exceptions

Exceptions are errors detected within your servlet. Exceptions can occur when JRun
translates a JSP to a Java class file, or when the servlet executes.
You represent exceptions in the following ways:

Maintaining page context information

The JSP pageContext object provides a mechanism for storing information that is local
to the JSP. JRun creates a new pageContext object for each page request; the object is
created when the page is invoked, and destroyed when the page completes. Methods of
the pageContext object let you access information about the JSP and perform other
actions.
Java Servlets have no equivalent object.
Associated listener interfaces
ServletContextListener
ServletContextAttributeListener
HttpSessionListener
HttpSessionAttributeListener
Logging
Managing sessions
Tracking application server resources
In a Java Servlet, an exception is represented by an instance of the
javax.servlet.ServletException
In a JSP, you reference an exception using the
class.
object.
exception
Servlets and JSPs
43

Advertisement

Table of Contents
loading

This manual is also suitable for:

Jrun 4

Table of Contents