image
Front Controller
Start course
Difficulty
Intermediate
Duration
4h 56m
Students
119
Ratings
4/5
Description

This course takes an in-depth look at how to use design patterns in your Java projects. We will then run through some example questions of what you could expect from the Oracle Certified Java EE exam.

Learning Objectives

  • Understand what design patterns are
  • Learn about the myriad of design patterns that you can use in your projects

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

 

Transcript

Hello dear friends. In this video, we will examine the front controller pattern. 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 dispatched to 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 a 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 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. Helpers 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 the 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 bean. 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, 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 processed the request initially. And last, we need a controller. Define dispatcher. And now we need three methods. isAuthenticUser, trackRequest. Last one will be dispatchRequest. Now we have finished coding the structure, let's use it. First, define controller. Now, send manager request and employee request. And look, for manager, we can see managerView, and for employee request, we can see the employeeView. Now, with this video we have finished studying design patterns. In the next video we will start to solve topic questions. See you in the next video.

 

About the Author
Students
3960
Courses
64
Learning Paths
5

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.

Covered Topics