Front Controller
Definition
Using a single component to process application requests.
Where to use & benefits
- JSP or Servlet.
- Design request handling component.
- Channel all requests through a single location.
- Centralize request processing and view selection.
- Reduce business logic in a view
- Improve manageability of security
- Promote code reuse across requests
- Avoid code duplication
- Related patterns include
- Decorator use doFilter to decorate or modify one or more requests.
- Command combined with multiple requests.
- Intercepting Filter both centralize control of certain types of request processing.
- Page Controller -- an alternative way.
Example
Design a servlet to deal with all the requests. The logon page is the first request. When the logon is allowed, the controller will present contents to the user. If the user has further request by clicking a link or a button, such request will be sent to the controller and the controller will decide if such request is granted or not, if so, the next page will be presented to the user, and so on.
Return to top