A Philadelphia based cable company is using J2EE for their Customer Management system. The system uses a combination of HTML and JSP for presentation. Java Servlets are used as Controllers. All Servlets have access to a ServletContext object, which functions as a Container to the shared resources of the Servlets. The ServletContext object best exemplifies what design pattern?
-
Iterator
-
Mediator
-
Interpreter
-
State
-
Singleton
E
Correct answer
Explanation
The ServletContext object acts as a Singleton - there is exactly one ServletContext instance per web application that all servlets share. This shared context holds application-wide resources and configuration, accessible to all servlets within that application. While Mediator, State, and Interpreter serve different purposes, the key here is the single shared container instance. Singleton ensures one instance exists and provides global access, which matches how ServletContext functions.