O'Reilly logo

J2EE™ Tutorial, The by Beth Stearns, Monica Pawlan, Eric Jendrock, Kim Haase, Dale Green, Stephanie Bodoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing the Web Context

The context in which Web components execute is an object that implements the ServletContext interface. You retrieve the Web context with 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, discussed in the section Filtering Requests and Responses (page 227). The filters store a counter as a context attribute. Recall from Controlling Concurrent Access to Shared Resources (page 220) that the counter’s access methods are synchronized to prevent incompatible operations by servlets that are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required