Want to create interactive content? It’s easy in Genially!
ADV_JAVA_UNIT6
Atharva Sawant
Created on November 14, 2022
Start designing with a free template
Discover more than 1500 professional designs like these:
View
Higher Education Presentation
View
Psychedelic Presentation
View
Vaporwave presentation
View
Geniaflix Presentation
View
Vintage Mosaic Presentation
View
Modern Zen Presentation
View
Newspaper Presentation
Transcript
SPRING WEB MVC FRAMEWORK
ADVANCE JAVA
Presentation By Atharva, Mayuri, Hardik From TY-BCA 2022-23
8. front controller
1. introduction
9. design components
2. SPRING WEB MVC
index
10. benefits of using MVC
3. mvc architecture
11. drawbacks of using mvc
4. FEATURES OF SPRING MVC
5. PROS & CONS OF MVC
12. DISPATCHER SERVLET IN mvc
6. FLOW OF SPRING MVC
7. REQUEST HANDLING IN MVC
13. CONTROLLERS IN MVC
14. thanks-GIVING
INTRODUCTION
The Spring Web MVC framework provides Model-View-Controller (MVC) architecture and ready components that can be used to develop flexible and loosely coupled web applications. The MVC pattern results in separating the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements. The Model encapsulates the application data and in general they will consist of POJO. The View is responsible for rendering the model data and in general it generates HTML output that the client's browser can interpret. The Controller is responsible for processing user requests and building an appropriate model and passes it to the view for rendering.
2003
The Spring Web Model View Controller (MVC)
The Spring Web Model View Controller (MVC) framework aids in the creation of web applications by offering comprehensive and in-depth support for Java applications. The framework is used to create online applications and is adaptable, reliable, and well-designed. The Spring MVC framework makes it simpler to construct, comprehend, and maintain online applications. The Java servlet and JSP languages are used to construct the Spring MVC framework.
MVC ARCHITECTURE
Model It is known as the lowest level which means it is responsible for maintaining data. Handle data logically so it basically deals with data.
View Data representation is done by the view component. It actually generates UI or user interface for the user.
Controller It’s the main man because the controller is the component. IT enables the interconnection between the views and the model.
MVC is an architectural design pattern used in the creation of web applications. The business entities that can be provided to the View via the Controller and then displayed to the user are stored in this model. The View, which represents an applications presentation form, is independent of the Model and Controller. The Controller is separate from the Model and View and exists just to manage requests and carry out business logic.
FEATURES OF MVC
POWERFUL FRAMEWORK AND CONFIGURATION: The Spring Web MVC framework provides straightforward and powerful configuration of the framework as well as of application classes such as JavaBeans. EASIER TESTING: The Spring MVC framework also provides classes to handle HTTP requests, which make the unit testing of the web application much easier. SEPERATION OF ROLES: Each component of a Spring MVC framework does a different role during request handling. A request is handled by components such as the Controller, Validator, Model Object, View Resolver and HandlerMapping interfaces.
NO NEED FOR DUPLICATION OF CODE:In the Spring MVC framework, we can use the existing business code in any component of the Spring MVC application. Therefore, no duplication of the code uprises in a Spring MVC application. SPECIFIC VALIDATION & BINDING: Validation errors are displayed when any unmatched data is entered in a form.
ADVANTAGES & DISADVANTAGES OF MVC
ADVANTAGES:
LIGHT-WEIGHT:This uses light-weight Servlet container to develop and deploy your application. FAST DEVELOPMENT: The Spring MVC facilitates rapid and parallel development. REUSABLE BUSINESS CODE: Instead of creating new objects, it allows us to use the existing business objects.
DISADVANTAGES:
NO SPECIFIC GUIDELINES:It does not care about XSS or cross-site scripting. With this in mind, we need to figure out ways on how to stop hackers from infiltrating your application. HIGH LEARNING CURVE: If you have not development experience in the field, it would be quite difficult to learn It is difficult due to new programming methods. LOTS OF XML: Developing a Spring application requires lots of XML.
FLOW OF SPRING MVC
As displayed in the figure, all the incoming request is intercepted by the Dispatcher Servlet that works as the front controller. The DispatcherServlet gets an entry of handler mapping from the XML file and forwards the request to the controller. The controller returns an object of ModelAndView. The DispatcherServlet checks the entry of view resolver in the XML file and invokes the specified view component.
Request handling in mvc
The figure above shows the low of request handling in Spring MVC, along with its components. They are explained as below.
DispatcherServlet: The Servlet intercepts and analyzes the incoming HTTP request and dispatches them to the suitable controller to be processed.
Filter: The Filter component applies to all the HTTP requests. Various commonly used filters can be used to fulfill the HTTP requests.
Controller: The Controller in Spring MVC acquires requests from DispatcherServlet class & does some business logic in accordance with the client.
Local resolution and theme resolution: The configuration of i18n and themes is defined in DispatcherServlet WebApplicationContext.It provides support to all the requests.
View: In Spring MVC, the View components are user- interface elements, such as textbox items and many others, which are responsible for displaying the output of a Spring MVC application.
Handler mapping: This maps the HTTP request to the handler, that is, a method within a Spring MVC controller class.
FRONT CONTROLLER DESIGN
The Front Controller Design Pattern refers that all requests that come for a resource in an application will be handled by a single handler and then dispatched to the suitable handler for that type of request. The main front controller may use other helpers to accomplish the dispatching mechanics.
let us see the components of front controller design in the next slide
Controller : The controller is the first contact point for handling all requests in the system. The controller may delegate to a helper to finish authentication and authorization of a user or to negin contact retrieval.
View: A view represents and shows information to the client. The view retrieves information from a model. Helpers support views by encapsulating and adapting the underlying data model for using in the display.
THE DESIGN COMPONENTS
Helper : A helper is responsible for helping a view or controller complete its processing. So, helpers have many responsibilities, including gathering data needed by the view and storing this intermediate model.
Dispatcher: A dispatcher is answerable for view management and navigation, management of the choice of the next view to represent to the user, and providing the mechanics for vectoring control to that resource.
TO DIVE DEEPER INTO IT, LET US HAVE A LOOK AT THE BENEFITS OF FRONT CONTROLLER
Focused control : TheFront controller handles all the requests to the Web application. This implementation of focused control that ignores using multiple controllers is desirable for imposing application-wide policies such as users tracking and safety.
Thread safety : A new command object uprises when receiving a new request and the command objects are not meant to be thread-safe. Thus, it will be safe in the command classes.
Configurability : Since only one front controller is needed in web application, the configuration of web applications implementation is largely simplified. The handler accomplishes the rest of dispatching so that it is not required to change anything before adding new commands with dynamic ones.
YOU MUST BE WONDERING ABOUT THE DRAWBACKS OF THE SAME
⋅It is not possible to scale an application using a front controller. ⋅The scaling up the application requires additional programming. ⋅It has several performance issues. ⋅Performance is better if you deal with a single request uniquely.
DIspatcherservlet in spring mvc
Spring's web MVC framework is, like many other web MVC frameworks, request-driven, designed around a centralized Servlet that dispatches requests to controllers and provides other functionality that serves the development of web applications. Spring's DispatcherServlet however, does more than just that. It is totally integrated with the Spring IoC container and as such allows us to use every other characteristic that Spring class is having.
CONTROLLERS IN SPRING MVC
The controller interprets user input and converts this input into a specific model which will be represented by the view to the user. While developing web functionality, we will develop resource-oriented controllers. Rather than each use case having one controller in the web application, we will have a single controller for each resource that the Spring web application serves. We don‘t need to inherit any specific interface or class while developing a controller based on Spring MVC using the @Controller annotation.
It’s audiences like you that make presentations awesome. Thank you very much for your unwavering attention throughout this presentation. Cheers :)
ThankYou!