10.4. Example: Monitoring Changes to Commonly Used Data

Section 10.2 shows how to read the current and former company names when the Web application is loaded and how to make use of those values in JSP pages. But what if you want to change the company name during the execution of the Web application? It is reasonable to expect a routine that makes this change to modify the companyName servlet context attribute. After all, in this context, that’s what it means to change the company name. It is not reasonable, however, to expect that routine to modify (or even know about) the formerCompanyName attribute. But, if the company name changes, the former company name must change as well. Enter servlet context attribute listeners!

The following steps ...

Get More Servlets and JavaServer Pages™ 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.