Introduction to Struts What is Struts Framework to



















- Slides: 19
Introduction to Struts
What is Struts Framework to develop web applications Open source Based on MVC-Model 2 pattern Apache Jakarta Project Current release is 1. 2. 7 Developed in May 2000 and June 2001
What is Frame work Frameworks are reusable, “semicomplete'' applications that can be applied to produce custom applications Frameworks are tested, proven software designs and implementations that reduce the cost, accelerate development speed and improve the quality of software
Benefits of Struts Frameworks Provide developers with modular, reusable and extensible software components Modular frameworks reduce the time and effort and investment required to understand maintain existing software
Contributes improvements in programmer productivity, as well as enhancing the quality, performance, reliability of the software. Reduces the cost of building and maintaining software
What is the MVC Pattern? MVC was first introduced by Small. Talk The goal of the MVC design pattern is to separate the application object (model) from the way it is represented to the user (view) from the way in which the user controls it (controller) i. e. layer architecture.
Components within the MVC Pattern? The model provides a representation of the data to the components comprising the view. It also knows about all the operations that can be applied to transform the data. The view provides presentation services in the application, such as a data entry screen or a screen rendering a query result.
The controller is responsible for linking the view with the model. The controller can be thought of as the controlling influence on the state of the model. All paths of navigation in the application are channelled through the controller.
What is MVC-Model 2 Business Layer Controller Form submit HTTP Event Servlet Create/Set property Browser Forward Model Java. Bean View HTTP Response JSP HTML Stylesheets Get property
What is Struts MVC-Model 2 Controller Http Event Action. Servlet Browser forward create Action. Form dispatch Business Logic Action Struts. Config. xml forward Http Response Business Layer View JSP Resource Bundle get create/set Model Java. Bean
What is Struts Architecture? The model is comprised of a combination of EJBs, Java Beans, and a set of Java classes extending the Struts base class Action. Form The view is represented by JSPs. The controller is implemented by the Struts Action. Servlet.
You can extend the controller’s behavior by creating Action classes to trigger the execution of a user request.
How to build a Struts application? Build the Model Components (Action. Form Class) Build the Controller Components (Action Class) Build the View Components (JSPs) Create the struts-config file Update the web. xml file
Building an Action. Form The Action. Form (also called the form) is a data holder that contains the data entered trough an HTML form. The form should also contain the get & set methods for each property. The form may also implement a validate method to perform data entry validations before actually performing the requested action. To create a form, you will need to extend the class org. apache. struts. action. Action. Form
Building an Action. Servlet is used to control the request and send the appropriate response to that request. It transforms request parameters into Action. Form There is only one Action. Servlet in the application. Package is used org. apache. struts. action. Action. Servlet
Building a JSP To create a JSP using Struts you will use the tag libraries provided by the Struts Framework. struts-logic. tld : This tag library contains tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. struts-html. tld : This taglib contains tags used to create struts input forms, as well as other tags generally useful in the creation of HTMLbased user interfaces.
Create the struts-config. xml file To allow for better reusability, all components in Struts are loosely coupled. To integrate the components you must create a config file (struts-config. xml) Within this file you’ll define the actionmappings and form-beans. The action-mappings tell the Action. Servlet which action classes to include within the application. The form-beans define the Action. Form classes required within the application.
Other Resources Struts homepage The Jakarta Project 12/12/2021 ttp: //jakarta. apache. org/struts/ 12/12/2021 ttp: //jakarta. apache. org Search on 12/12/2021 ttp: //www. google. com Search criteria ‘jakarta struts’
Thanks Yashwant Chavan. ITShastra (INDIA) Pvt. Ltd.