J2EE pattern • Presentation
J2EEPresentationJava example
Dispatcher View solves a specific structural problem in the design.
Use a controller to gather model data, then forward to a rendering view.
Pattern overview
J2EE pattern
Use a controller to gather model data, then forward to a rendering view.
Intent
Combine request handling and view rendering with a dispatch step that hands prepared data to the view.
Problem
Pages need controller logic, but templates should stay focused on rendering.
Solution
Have a controller collect data and dispatch to a dedicated view.
Fit and tradeoffs
FamilyJ2EE
CategoryPresentation
Best used when
- For server-rendered pages where controller logic prepares the model.
Tradeoffs
- Can drift into fat controllers if domain orchestration is not pushed down.
Java example
This example is intentionally compact so the pattern shape stays easy to see.
@GetMapping("/account")
String account(Model model) {
model.addAttribute("profile", accountService.loadProfile());
return "account";
}