Accessing the Web Context
The context in which Web components execute is an object that implements the ServletContext interface. You retrieve the Web context using the getServletContext method. The Web context provides methods for accessing:
Initialization parameters
Resources associated with the Web context
Object-valued attributes
Logging capabilities
The Web context is used by the Duke's Bookstore filters filters.HitCounterFilter and OrderFilter, which are discussed in Filtering Requests and Responses (page 454). Each filter stores a counter as a context attribute. Recall from Controlling Concurrent Access to Shared Resources (page 445>) that the counter's access methods are synchronized to prevent incompatible operations by servlets that are ...
Get The J2EE™ Tutorial Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.