Master Software Architecture & Design Patterns!
Subscribe to Ram N Java for beginner-friendly, practical software engineering guides!
🔔 Subscribe to Our ChannelWhat is the Page Controller Pattern?
The Page Controller design pattern belongs to the web presentation patterns family in enterprise application architecture. In simple terms, a Page Controller is an object that handles a request for a specific page or action on a website.
Under this architectural pattern, there is a direct one-to-one mapping between pages and controllers: each logical page or user action has its own dedicated input controller.
How Does Page Controller Work?
The request handling cycle follows a straightforward flow for every page:
- Request Interception: When a user submits an action or navigates to a URL (e.g., a JSP view), the dedicated Page Controller intercepts the request.
- Model Update: The controller extracts request parameters and updates or queries the domain model.
- View Dispatching: Based on the updated model state or outcome, the controller determines which view (or JSP page) should be rendered and returned to the client.
Real-World Example: Address Management
Consider a web application with two distinct JSP pages:
searchAddress.jsp: Allows users to search for addresses in the database and displays the results.addAddress.jsp: Contains a form where users submit new address records to be saved.
Following the Page Controller pattern, we create two separate controllers:
- SearchAddressController: Exclusively handles requests from
searchAddress.jsp, calls the search service, and forwards the results. - AddAddressController: Exclusively handles form submissions from
addAddress.jsp, passes new records to the persistence layer, and directs the user to a success confirmation view.
Watch Related Architecture Tutorials:
Click here to watch in Youtube : https://www.youtube.com/watch?v=SMLwqqqcAnE
Click the below Image to Enlarge
| Page Controller Design Pattern |
| Page Controller Design Pattern |
No comments:
Post a Comment