STRUTS * A FRAMEWORK TO DEVELOP WEB APPLICATION EASILY. * USING STRUTS, IT MAKES EASIER TO DEVELOP WEB APPLICATION AND MAINTAIN THE,/ * STRUTS IS AN OPEN SOURCE FRAMEWORK WHICH MAKES BUILDING WEB APPLICATIONS EASIER, BASED ON JAVA SERVLETS ANS JSP TECHNOLOGIES. * THE STRUTS FRAMEWORK WAS CREATED BY CRAIG R. MCCLANAHAN AND WAS DONATED TO THE APACHE FOUNDATION IN 2000. * MVC Model 2 is not a framework. A framework is a readily made solution offered by a company. * Runs on MVC * Memory-consuming Why Struts? What is wrong with JSP / Servlets * Using only Servlets - it is difficult to output html and needs a lot of println's * Using only JSP, added scriptlets and implicit objects into JSP, awkward to see java inside html, hard to read and maintain, useful if very small application * Using JSP + Java Beans - Code inside beans and JSP to display. Good choice for small applications. But what if there is need of multiple type of views? E.g: If there is a need of different language display depending on client location? - making request to a general servlet ADVANTAGES OF MVC * Reliability * Reusability * Low Development Costs * Rapid Development * Maintainability * MVC MODEL 2 APPROACH: 1 REQUEST - ONE CONTROLLER * MVC MODEL 2 ARCHITECTURE: ALL REQUESTS - ONE CONTROLLER WHAT IS A FRAMEWORK? * A web application framework is a piece of structural software that provides automation of common tasks as well as a built-in architectural solution that can be easily inherited by applications, implemented on the framework. STRUTS * Comes with all jars you might need to develop basic request-response cycle, and with basic configuration. (84) * Provides the controller servlet or filter which will read your request and convert it to integer or float according to requirements. * Framework contains exceptions and displays your exact message * After all conversions, the framework automatically populates all your data needed from form to the java object. * You don’t have to write much code to validate all your form data. Framework provides some basic automatic validations. * After you write business logic, you don’t have to write code to dispatch request to another page, through the form of an XML file * One controller for all requests (MVC Model 2 Architecture) - filter, in the form of an XML file * Forces the team to implement code in a standard way (Action class method) * Might also help you develop complex UI easily like iterating tables, the menu, etc. * Using frameworks like Struts 2.0, one need not have to have deep knowledge of HTTP protocol and its request and responses interfaces to write business logic. WHY APPLICATION FRAMEWORKS? * Most model 2 architecture based web applications share a common set of functionality. For examples, they all do receive and dispatch HTTP requests, invoking model methods, selecting and assembling views. * If everybody is doing the same thing over and over again every time, spending less time on business logic. STRUTS 2 MVC COMPOSITION * Controller * Filter Dispatcher * Interceptors * Can execute code before and after an action is executed. * They can be configured per action basis * They can be used for data validation, file upload, double submit guards