Front Controller Design Pattern
Start course
3h 59m

In this course, we will learn the concepts of microservice and spring framework with a focus on design patterns.

Learning Objectives

  • Learn about various design patterns

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud


  • Basic Java knowledge

Hello dear friends. In this video, we will examine the front controller pattern. So, let's begin. The front controller design pattern means that all requests that come for a resource in an application will be handled by a single handler and then dispatch the appropriate handler for that type of request. The front controller may use other helpers to achieve the dispatching mechanism. The front controller software design pattern is listed in several pattern catalogs and related to the design of web applications. It is a controller that handles all requests for our website, which is a useful structure for web application developers to achieve flexibility and reuse without code redundancy. Front controller pattern has four participants. The controller is an entrance for users to handle requests in the system.

It realizes authentication by playing the role of delegating helper or initiate contact retrieval. Front controller is a single handler for all kinds of requests coming to the application. Views are the object for which the requests are made. A view represents and displays information to the client. The view retrieves information from a model. Helper support views by encapsulating and adapting the underlying data model for use in the display. Dispatchers can be used for navigation and managing the view output. Users will receive the next view that is determined by the dispatcher. Dispatchers are also flexible. They can be encapsulated within the controller directly or separated to another component. The dispatcher provides a static view along with a dynamic mechanism.

A helper is responsible for helping a view or controller complete its processing. Thus helpers have numerous responsibilities, including gathering data required by the view and storing this intermediate model, in which case the helper is sometimes referred to as a value being. I think that's enough for now. Let's write some code and put this pattern into practice. Create a new project and name it FrontController. First, we need two views: EmployeeView, showView. Let's add for manager, showView. Okay, done. Now we need a dispatcher. First, define views. Now in constructor, we will use them. Now let's define the dispatch method. A request for either of these two can come up at any point. We use the dispatcher to deal with the request pointing to the correct view after the front controller process the request initially.

And last we need a controller. Define dispatcher. Now we need three methods: isAuthenticUser, trackRequest. Last one will be dispatchRequest. Now we've finished coding the structure, let's use it. First, define controller. Now send manager request and employer request. And look for a manager. We can see ManagerView, and for employee request we can see the EmployeeView, so great. Now with this video, we have finished studying design patterns. So, I'll see you in the next video.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.