The document provides an overview of Struts, an open source MVC framework for building web applications in Java. It discusses the key components of Struts, including the controller, request processor, actions, and action mappings. The controller acts as the central coordinator and uses action mappings configured in XML to route requests to the appropriate actions. Actions perform business logic and return a forwarding path. The framework handles request processing and forwarding the response to the corresponding view.
This document provides an introduction to Jakarta Struts 1.3, an open source MVC framework for building Java web applications. It discusses the limitations of using the traditional MVC pattern for web applications due to HTTP's stateless nature. Struts implements an MVC2 pattern to address this, using the controller to manage state. The core Struts components like ActionForms, Actions, and ActionMappings are explained. It also covers setting up the Struts controller through configuration files, defining forms and actions, and creating views with JSP and custom tag libraries.
This ppt tells about struts in java. All the methods and brief knowledge of struts. For more info about struts and free projects on it please visit : http://s4al.com/category/study-java/
This document provides an overview of Spring MVC including:
- Spring MVC is a web framework built on the Servlet API that uses the MVC pattern. It features a DispatcherServlet that handles requests and delegates to controllers.
- The request processing workflow in Spring MVC involves the DispatcherServlet dispatching tasks to controllers, which interact with services and return a view name. The view is then rendered using a ViewResolver.
- Spring MVC applications use a WebApplicationContext containing web-related beans like controllers and mappings, which can override beans in the root context. Configuration can be done via XML or Java-based approaches. Important annotations map requests and bind parameters.
This document provides an overview of the Struts framework, which implements the Model-View-Controller design pattern for JavaServer Pages. It describes the core components of Struts, including action handlers, result handlers, and custom tags. It also explains how Struts uses interceptors to apply common functionality like validation. Finally, it provides a step-by-step example of creating a basic login application using Struts.
Spring MVC 3.0 Framework
Objective:
1. Introduce Spring MVC Module
2. Learn about Spring MVC Components (Dispatcher, Handler mapping, Controller, View Resolver, View)
Slides:
1. What Is Spring?
2. Why use Spring?
3. By the way, just what is MVC?
4. MVC Architecture
5. Spring MVC Architecture
7. Spring MVC Components
8. DispatcherServlet
9. DispatcherServlet Architecture.........
.........................................................
Spring MVC provides a lightweight framework for building web applications. It separates concerns into modules with distinct roles like controllers, models and views. This makes applications highly configurable, reusable and easy to test. The framework uses annotations and inversion of control for configuration which promotes loose coupling and rapid development. Core components include the DispatcherServlet, controllers, models and view resolvers.
Apache Struts is an open source MVC framework for developing Java web applications. It divides applications into three parts - the model contains application logic and database connection code, the view is the user interface like HTML/JSP pages, and the controller acts as an interface between the user and model. Struts uses the MVC pattern to separate business logic from presentation for easy maintenance of web applications.
This document provides an introduction to Jakarta Struts 1.3, an open source MVC framework for building Java web applications. It discusses the limitations of using the traditional MVC pattern for web applications due to HTTP's stateless nature. Struts implements an MVC2 pattern to address this, using the controller to manage state. The core Struts components like ActionForms, Actions, and ActionMappings are explained. It also covers setting up the Struts controller through configuration files, defining forms and actions, and creating views with JSP and custom tag libraries.
This ppt tells about struts in java. All the methods and brief knowledge of struts. For more info about struts and free projects on it please visit : http://s4al.com/category/study-java/
This document provides an overview of Spring MVC including:
- Spring MVC is a web framework built on the Servlet API that uses the MVC pattern. It features a DispatcherServlet that handles requests and delegates to controllers.
- The request processing workflow in Spring MVC involves the DispatcherServlet dispatching tasks to controllers, which interact with services and return a view name. The view is then rendered using a ViewResolver.
- Spring MVC applications use a WebApplicationContext containing web-related beans like controllers and mappings, which can override beans in the root context. Configuration can be done via XML or Java-based approaches. Important annotations map requests and bind parameters.
This document provides an overview of the Struts framework, which implements the Model-View-Controller design pattern for JavaServer Pages. It describes the core components of Struts, including action handlers, result handlers, and custom tags. It also explains how Struts uses interceptors to apply common functionality like validation. Finally, it provides a step-by-step example of creating a basic login application using Struts.
Spring MVC 3.0 Framework
Objective:
1. Introduce Spring MVC Module
2. Learn about Spring MVC Components (Dispatcher, Handler mapping, Controller, View Resolver, View)
Slides:
1. What Is Spring?
2. Why use Spring?
3. By the way, just what is MVC?
4. MVC Architecture
5. Spring MVC Architecture
7. Spring MVC Components
8. DispatcherServlet
9. DispatcherServlet Architecture.........
.........................................................
Spring MVC provides a lightweight framework for building web applications. It separates concerns into modules with distinct roles like controllers, models and views. This makes applications highly configurable, reusable and easy to test. The framework uses annotations and inversion of control for configuration which promotes loose coupling and rapid development. Core components include the DispatcherServlet, controllers, models and view resolvers.
Apache Struts is an open source MVC framework for developing Java web applications. It divides applications into three parts - the model contains application logic and database connection code, the view is the user interface like HTML/JSP pages, and the controller acts as an interface between the user and model. Struts uses the MVC pattern to separate business logic from presentation for easy maintenance of web applications.
This document provides an overview of developing a web application using Spring Boot that connects to a MySQL database. It discusses setting up the development environment, the benefits of Spring Boot, basic project structure, integrating Spring MVC and JPA/Hibernate for database access. Code examples and links are provided to help get started with a Spring Boot application that reads from a MySQL database and displays the employee data on a web page.
The document provides an introduction to ASP.NET MVC architecture. It discusses the key components of MVC - the model, view and controller. The model handles the data and logic, the view displays the UI, and the controller coordinates between them. It also covers MVC conventions like controller and view directories, and compares ASP.NET MVC to Web Forms.
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
ASP.NET MVC is a framework from Microsoft that separates an application's logic, presentation, and data access into three distinct components: models, views, and controllers. This separation of concerns makes the application easier to manage, test, and develop for large teams. ASP.NET MVC uses friendly URLs, does not rely on view state or server-based forms, and supports test-driven development better than traditional ASP.NET Web Forms applications.
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
The document provides an overview of ASP.NET MVC, including its core components and how they differ from ASP.NET Web Forms. It discusses Models, Views, Controllers, validation, routing, unit testing, and view engines. Key points covered include MVC separating application logic, control over HTML, testability, and no viewstate or postbacks. Examples are provided for creating controllers and actions, passing data to views, validation, routing, and unit testing.
- jQuery is a JavaScript library that simplifies HTML document traversal and manipulation, as well as event handling, animation, and Ajax.
- It works by allowing the selection of HTML elements and running functions on those elements via a simple and consistent API.
- Common uses of jQuery include modifying HTML content, CSS styling, handling user events, animating elements, and loading data from web servers via Ajax.
This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include:
- JavaScript can change HTML content, styles, validate data, and make calculations.
- Functions are blocks of code that perform tasks when invoked by events or called in code.
- Events like clicks or keyboard presses trigger JavaScript code.
- The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify.
- Forms and user input can be accessed and processed using the DOM.
- Programming flow can be controlled with conditional and loop statements.
-
The document provides an overview of jQuery including:
- What jQuery is and its main features like DOM manipulation and AJAX
- How to include jQuery in an HTML document and basic usage syntax
- jQuery selectors to find elements and filters to refine selections
- Common jQuery methods for manipulating attributes, events, HTML, CSS, and more
- Examples of using various jQuery functions and concepts
JavaScript is a scripting language originally designed for web browsers but now used everywhere. It has dynamic typing and supports object-oriented, imperative, and functional programming. JavaScript was created in 1995 and standardized in 1999. It is now the most popular language on GitHub. JavaScript can be used to build interactive web pages, desktop applications, server-side applications, IoT applications, and real-time applications. The core data types in JavaScript are Number, String, Boolean, Object, Function, Array, Date, and Regular Expressions. JavaScript supports features like variables, flow control, error handling, debugging, and JSON for data exchange.
This document provides an overview of Spring MVC, the model-view-controller framework for building web applications in Spring. It discusses Spring MVC's request processing workflow including the front controller and application context. It also covers controllers, mapping requests, returning views and data representation. Key topics include RESTful design, annotations like @RequestMapping and return types, and view resolvers for resolving JSP and other view technologies.
This document provides an overview of AJAX and jQuery. It begins by stating the objectives of the document, which are to identify the AJAX web application model, work with AJAX and jQuery, implement selectors, manipulate the DOM, implement jQuery UI widgets. It then provides information on introducing AJAX, including how it allows asynchronous updating of web pages. It describes the components that AJAX uses, including XMLHttpRequest, JavaScript, DOM, and CSS. It also provides examples of how AJAX is used in real-life scenarios and browsers that support AJAX.
JavaScript variables hold values and are declared with var. Variable names are case sensitive and must begin with a letter or underscore. Variables can hold numbers, strings, Booleans, objects, and null values. Arrays are objects that hold multiple values in a single variable. Functions are blocks of code that perform tasks and are executed by events or calls. Objects store related data and functions to represent self-contained entities.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
The document provides an introduction to React, a JavaScript library for building user interfaces. It discusses key React concepts like components, properties, state, one-way data flow, and JSX syntax. It also covers setting up a development environment with Create React App and shows how to create a basic React component with state. The target audience appears to be people new to React who want to learn the fundamentals.
If you don't have knowledge of HTML, CSS & JavaScript than you may face some difficulties in validating a HTML form yet I will make the entire step very easy to understand by you.
This document provides an overview of socket programming in Java. It discusses how client-server applications use sockets to communicate over a network. Sockets are identified by an IP address and port number. The document explains TCP and UDP socket programming in Java. For TCP, it describes how the server creates a welcoming socket to accept client connections. For both TCP and UDP, it outlines the basic interactions between client and server sockets. The document concludes by noting that socket programming is easy in Java and real-time applications typically use threads to handle each socket.
The document provides an overview of the Struts framework, including its advantages and components. It discusses the Model 1 and Model 2 architectures, and explains that Struts implements the MVC pattern. It describes the controller elements like the action servlet and request processor, the model components like Java classes and beans, and the view components like JSP tag libraries. The document also provides examples of how Struts can be implemented in a sample application.
Step by Step Guide for building a simple Struts Applicationelliando dias
This document provides a step-by-step guide for building a simple Struts application. It outlines 8 steps: 1) Create the development directory structure, 2) Write the web.xml file, 3) Write the struts-config.xml file, 4) Write ActionForm classes, 5) Write Action classes, 6) Create resource properties files, 7) Write JSP pages, and 8) Write the Ant build script. For each step, it provides details on what to include and examples of code.
This document provides an overview of developing a web application using Spring Boot that connects to a MySQL database. It discusses setting up the development environment, the benefits of Spring Boot, basic project structure, integrating Spring MVC and JPA/Hibernate for database access. Code examples and links are provided to help get started with a Spring Boot application that reads from a MySQL database and displays the employee data on a web page.
The document provides an introduction to ASP.NET MVC architecture. It discusses the key components of MVC - the model, view and controller. The model handles the data and logic, the view displays the UI, and the controller coordinates between them. It also covers MVC conventions like controller and view directories, and compares ASP.NET MVC to Web Forms.
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
ASP.NET MVC is a framework from Microsoft that separates an application's logic, presentation, and data access into three distinct components: models, views, and controllers. This separation of concerns makes the application easier to manage, test, and develop for large teams. ASP.NET MVC uses friendly URLs, does not rely on view state or server-based forms, and supports test-driven development better than traditional ASP.NET Web Forms applications.
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
The document provides an overview of ASP.NET MVC, including its core components and how they differ from ASP.NET Web Forms. It discusses Models, Views, Controllers, validation, routing, unit testing, and view engines. Key points covered include MVC separating application logic, control over HTML, testability, and no viewstate or postbacks. Examples are provided for creating controllers and actions, passing data to views, validation, routing, and unit testing.
- jQuery is a JavaScript library that simplifies HTML document traversal and manipulation, as well as event handling, animation, and Ajax.
- It works by allowing the selection of HTML elements and running functions on those elements via a simple and consistent API.
- Common uses of jQuery include modifying HTML content, CSS styling, handling user events, animating elements, and loading data from web servers via Ajax.
This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include:
- JavaScript can change HTML content, styles, validate data, and make calculations.
- Functions are blocks of code that perform tasks when invoked by events or called in code.
- Events like clicks or keyboard presses trigger JavaScript code.
- The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify.
- Forms and user input can be accessed and processed using the DOM.
- Programming flow can be controlled with conditional and loop statements.
-
The document provides an overview of jQuery including:
- What jQuery is and its main features like DOM manipulation and AJAX
- How to include jQuery in an HTML document and basic usage syntax
- jQuery selectors to find elements and filters to refine selections
- Common jQuery methods for manipulating attributes, events, HTML, CSS, and more
- Examples of using various jQuery functions and concepts
JavaScript is a scripting language originally designed for web browsers but now used everywhere. It has dynamic typing and supports object-oriented, imperative, and functional programming. JavaScript was created in 1995 and standardized in 1999. It is now the most popular language on GitHub. JavaScript can be used to build interactive web pages, desktop applications, server-side applications, IoT applications, and real-time applications. The core data types in JavaScript are Number, String, Boolean, Object, Function, Array, Date, and Regular Expressions. JavaScript supports features like variables, flow control, error handling, debugging, and JSON for data exchange.
This document provides an overview of Spring MVC, the model-view-controller framework for building web applications in Spring. It discusses Spring MVC's request processing workflow including the front controller and application context. It also covers controllers, mapping requests, returning views and data representation. Key topics include RESTful design, annotations like @RequestMapping and return types, and view resolvers for resolving JSP and other view technologies.
This document provides an overview of AJAX and jQuery. It begins by stating the objectives of the document, which are to identify the AJAX web application model, work with AJAX and jQuery, implement selectors, manipulate the DOM, implement jQuery UI widgets. It then provides information on introducing AJAX, including how it allows asynchronous updating of web pages. It describes the components that AJAX uses, including XMLHttpRequest, JavaScript, DOM, and CSS. It also provides examples of how AJAX is used in real-life scenarios and browsers that support AJAX.
JavaScript variables hold values and are declared with var. Variable names are case sensitive and must begin with a letter or underscore. Variables can hold numbers, strings, Booleans, objects, and null values. Arrays are objects that hold multiple values in a single variable. Functions are blocks of code that perform tasks and are executed by events or calls. Objects store related data and functions to represent self-contained entities.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
The document provides an introduction to React, a JavaScript library for building user interfaces. It discusses key React concepts like components, properties, state, one-way data flow, and JSX syntax. It also covers setting up a development environment with Create React App and shows how to create a basic React component with state. The target audience appears to be people new to React who want to learn the fundamentals.
If you don't have knowledge of HTML, CSS & JavaScript than you may face some difficulties in validating a HTML form yet I will make the entire step very easy to understand by you.
This document provides an overview of socket programming in Java. It discusses how client-server applications use sockets to communicate over a network. Sockets are identified by an IP address and port number. The document explains TCP and UDP socket programming in Java. For TCP, it describes how the server creates a welcoming socket to accept client connections. For both TCP and UDP, it outlines the basic interactions between client and server sockets. The document concludes by noting that socket programming is easy in Java and real-time applications typically use threads to handle each socket.
The document provides an overview of the Struts framework, including its advantages and components. It discusses the Model 1 and Model 2 architectures, and explains that Struts implements the MVC pattern. It describes the controller elements like the action servlet and request processor, the model components like Java classes and beans, and the view components like JSP tag libraries. The document also provides examples of how Struts can be implemented in a sample application.
Step by Step Guide for building a simple Struts Applicationelliando dias
This document provides a step-by-step guide for building a simple Struts application. It outlines 8 steps: 1) Create the development directory structure, 2) Write the web.xml file, 3) Write the struts-config.xml file, 4) Write ActionForm classes, 5) Write Action classes, 6) Create resource properties files, 7) Write JSP pages, and 8) Write the Ant build script. For each step, it provides details on what to include and examples of code.
This document discusses the Struts framework, which uses the Model-View-Controller (MVC) design pattern to separate the display logic from the business logic in Java-based web applications. It describes the core components of Struts, including the base framework, tag libraries, tiles plugin, and validator plugin. It also explains the MVC architecture, with the model managing the data/services, the view generating responses, and the controller handling requests and coordinating the model and view. In conclusion, the document notes that Struts takes complexity out of web application development and provides a stable, feature-rich, and flexible open-source platform.
Este documento presenta un resumen básico del framework Struts. Explica que Struts implementa el patrón MVC en Java y cómo funciona en aplicaciones web mediante solicitudes del navegador al controlador. También describe cómo Struts simplifica el desarrollo MVC separando la lógica del negocio, la vista y el controlador. El documento luego resume los componentes clave de Struts como el modelo, la vista y el controlador.
The document provides an overview of Struts 2, an open-source MVC framework for developing Java web applications. It discusses how Struts 2 uses plain POJO action classes and annotation-based configuration for simplifying code structure. The document also includes examples of Struts 2 validation and interceptors to reduce coupling. Finally, it lists the company's social media accounts for further contact.
This document provides an overview of the Struts framework and its key components. It covers the model-view-controller design pattern used in Struts, the model components including JavaBeans and ActionForm beans, view components like JSP tags and internationalization, controller components like Action classes and the configuration file, and finally the tag libraries used in Struts. The document is part of a training course on Struts and introduces each major concept across 9 units.
The document provides an overview of the Hibernate framework. It discusses some of the drawbacks of using JDBC for database access, such as needing to manually open and close connections. Hibernate aims to address these issues by providing object-relational mapping and allowing data to flow through an application as objects rather than being converted to text for storage. Some key advantages of Hibernate mentioned are that it supports inheritance, associations and collections, and allows saving derived class objects while also persisting base class data.
This document provides an introduction to building web applications using the Jakarta Struts framework. It discusses some of the challenges of building web applications and how Struts addresses these challenges through its implementation of the MVC pattern. It provides an overview of Struts' controller, model, and view components and how they work together. It also presents a case study of building an online poll application with Struts to demonstrate these concepts. Key benefits of Struts like separation of components and reusability are highlighted. The document concludes with tips on getting started quickly with Struts.
Liferay 6 и портлеты Vaadin. Введение и демонстрация Liferay IDE и портлеты на базе Vaadin.
Sami Ekblad, Vaadin
Vaadin Developer Meetup, Санкт-Петербург, 24 января 2011 года
Step By Step Guide For Buidling Simple Struts AppSyed Shahul
This document provides steps to build a simple Struts application, including creating forms, actions, configuration files, and JSP pages. The key steps are:
1. Set up the project directory structure and files like web.xml.
2. Define forms, actions, and mappings in struts-config.xml.
3. Create ActionForm classes to handle form fields and validation.
4. Write Action classes to process requests and select views.
5. Develop JSP pages to display forms and output using Struts tags.
6. Build, deploy and test the complete application.
The document discusses different approaches to integrating Struts 2 and Spring frameworks by separating application layers.
It presents three cases: 1) Using a simple POJO as the action; 2) Extending ActionSupport to decouple the action from business services; 3) Using business services and data transfer objects to further separate layers.
The key point is that the business layer should not be tied to any web framework like Struts or Spring MVC. Integration can be achieved by configuring business services for use by actions, while keeping each layer independent through separation of concerns.
Java & J2EE Struts with Hibernate FrameworkMohit Belwal
This document provides an overview of Java 2 Enterprise Edition (J2EE) and its core components. J2EE is a multi-tiered architecture for developing enterprise applications and web applications using Java technology. It uses a component-based model where components like servlets, JavaServer Pages (JSPs), and Enterprise JavaBeans (EJBs) interact with services provided by containers like web containers and EJB containers. The document discusses J2EE concepts, features, benefits, components, containers, and how applications are packaged and deployed. It also provides examples of servlets and JSPs as core web components in J2EE.
Liferay Developer Best Practices for a Successful Deploymentrivetlogic
Liferay is one of the leading open source portals in today’s market. However, it’s more than just a portal, it’s also a framework. And with good frameworks, comes flexibility, and with flexibility comes the need to understand and follow best practices.
This webcast will share lessons learned and best practices gathered from some of our very own customer Liferay implementations. The presentation will cover the gamut of a Liferay implementation lifecycle.
This document provides an overview of Struts 2, including:
- Struts 2 is an open source MVC framework that was originally known as WebWork 2.
- It follows the MVC architecture pattern with Actions as controllers, value stack/OGNL for models, and JSPs as views.
- The core components of Struts 2 are Actions, Interceptors, the value stack, Result types, and view technologies like JSP.
- The document discusses the Struts 2 architecture, creating a basic Struts 2 application, and additional topics like interceptors, validation, internationalization, and integrating with jQuery.
Struts2 course chapter 1: Evolution of Web ApplicationsJavaEE Trainers
The document outlines the topics covered in a Struts2 course, including evolution of web applications, Struts2 installation and configuration, actions and results, OGNL, form tags, generic tags, type conversion, input validation, internationalization, interceptors, persistence, file upload/download, security, custom interceptors, custom result types, preventing double submits, the execute and wait interceptor, decorating with Tiles and SiteMesh, zero configuration, and AJAX. It then provides more details on the evolution of web applications from no MVC to MVC model 1 and 2, and how Struts1 and Struts2 implement MVC model 2 with improvements like easier testing and reduced servlet dependencies.
This document provides an overview and summary of the Struts framework for building web applications:
- The Struts framework is based on the Model-View-Controller (MVC) architecture which divides applications into the model, view, and controller layers.
- Struts implements the front controller pattern where requests are handled by a central controller servlet that dispatches requests to application components.
- The framework provides tags and utilities to build web forms and interfaces, internationalization support, and an extensible validation framework.
- Configuration is done via XML files which define mappings, form beans, validators, and other application settings.
- An example application demonstrates common design patterns used with Struts like actions that
The document provides an overview and agenda for Struts 2.x. It discusses Struts Introduction, Struts Web Flow, Struts Architecture, Struts Basic Example, Dynamic Method Invocation, Multiple Struts.xml files, IOC and DI, Interceptors, Validation, Internationalization, Control Tags, Struts2 with Jquery, Build in Interceptor, Custom Interceptor, and I18N.
The document discusses the Struts framework, including its advantages in solving software development challenges through reusable components. It describes the Model-View-Controller architecture that Struts uses, with the controller directing requests to models for data and views for presentation. Key aspects of Struts like configuration files, actions, forms, tags and internationalization are explained at a high level.
This document discusses interceptors in Apache Struts 2.x. It defines interceptors as code that can execute before and after actions to handle common concerns like validation. The document explains how interceptors are configured and some built-in interceptors like ParametersInterceptor and ValidationInterceptor. It also outlines the disadvantages of Struts like its large learning curve and rigid approach compared to standard Java web development.
Struts is a web application framework that uses the MVC design pattern. It combines Java servlets, JavaServer Pages, custom tags and message resources. Struts acts as a controller in MVC that routes requests between the view (JSPs) and the model (business logic classes). Struts is open source software hosted by the Apache Software Foundation. It provides a standard way to build Java web applications by separating the application logic from the user interface.
The document provides answers to 12 interview questions about the Struts framework. It defines key concepts like MVC, frameworks, Struts framework, ActionServlet, Action classes, ActionForms, validation, and RequestProcessor. The questions and answers cover the responsibilities and roles of these core Struts components and how they implement the MVC architecture.
Struts An Open-source Architecture for Web Applicationselliando dias
The document provides an overview of Struts, an open-source MVC framework for building web applications in Java, discussing how to install and configure Struts, its core concepts like the MVC pattern, and how to develop applications using Struts including creating forms, actions, and tag libraries.
- Doris Chen presented on JavaServer Pages/Servlets and web application frameworks.
- She discussed the JSP/Servlet technology foundation and how frameworks like Struts, JavaServer Faces, and Sun ONE Application Framework build upon it.
- Struts is an open source MVC framework that uses Java servlets as controllers and JSPs as views. It utilizes configuration files and custom tags to coordinate requests between components.
Struts 2 is an open source MVC framework for building Java web applications that uses a simplified front controller design pattern and implements the MVC architecture with components like actions, interceptors, and views. It addresses some limitations of Struts 1 by having a simplified design, easier testing, support for annotations and AJAX, and removes dependencies on specific servlet APIs. The key components needed to start using Struts 2 are a Java 5.0 JDK and Tomcat 5.x or higher to provide the servlet and JSP APIs.
This document summarizes a presentation on the Struts 2 framework. It discusses the key components of Struts 2 including the controller, interceptors, actions, and results. It also covers the request and response cycle, architecture, differences from Struts 1, configuration file structure, tags, and the use of OGNL. The presentation provides an overview of the core functionality and design of the Struts 2 MVC framework.
This document provides an overview of the Struts framework, which implements the Model-View-Controller design pattern for JavaServer Pages. It discusses the core components of Struts, including action handlers, result handlers, and custom tags. It also explains how Struts uses interceptors to apply common functionality like validation. Finally, it provides an example of creating a basic login application using Struts.
Struts is an open source MVC framework for building Java web applications. It uses the MVC pattern and includes configurable components like actions, interceptors, and results. Struts 2 combines Struts 1 and WebWork and supports features such as AJAX, validation, dependency injection, and theming. The framework follows conventions where actions are POJOs mapped to requests and results in configuration files, with interceptors handling processing between the controller and views.
ASP.NET MVC is a framework that allows developers to apply the MVC pattern to ASP.NET applications. This separates the application into three components - the Model, View, and Controller. The Controller handles requests and interacts with the Model, which contains business logic. The View displays the user interface and data from the Model. This separation of concerns allows for better reusability and easier testing compared to the standard ASP.NET web forms model.
The document discusses the MVC architecture pattern and how it is commonly implemented using Java technologies like Servlets, JSPs, and frameworks like Struts. It describes the core components of MVC - the Model, View, and Controller layers. The Model contains the business logic and data access code. The View is responsible for presentation and user interface. The Controller accepts user input and interfaces with the Model to handle requests. Frameworks like Struts provide libraries and utilities to simplify building applications using the MVC pattern.
J2EE assignment
hello friends your helpful some question and answer for subject
advance java
most useful smt . j.j kundalia commerce college students assignment j2ee with answer..
your like my content ,share and your suggestion me send upgrade contents .
This document provides information about the Struts and Spring frameworks. It discusses that Struts is an open-source MVC framework that uses servlets and tag libraries to build Java web applications. Spring is a lightweight, modular framework that can be used to build full applications across all layers, unlike Struts which focuses on the presentation layer. The document compares features of Struts and Spring such as their architectures, modules, and differences in how requests are handled.
The document discusses design patterns and architectural patterns, specifically focusing on the model-view-controller (MVC) pattern. It provides an overview of MVC, explaining the model, view, and controller components. It then describes how MVC is implemented in ASP.NET MVC, including the request flow and separation of concerns. Some key benefits of ASP.NET MVC like clean URLs, testability, and extensibility are also summarized.
Struts 2 is an open source MVC framework based on Java EE standards. It uses a request-response pipeline where interceptors pre-process and post-process requests. The core components are interceptors, actions, and results. Interceptors provide functionality like validation while actions contain application logic and results define the response. Values are stored and accessed from a value stack using OGNL.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
“An Outlook of the Ongoing and Future Relationship between Blockchain Technologies and Process-aware Information Systems.” Invited talk at the joint workshop on Blockchain for Information Systems (BC4IS) and Blockchain for Trusted Data Sharing (B4TDS), co-located with with the 36th International Conference on Advanced Information Systems Engineering (CAiSE), 3 June 2024, Limassol, Cyprus.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
2. Sang Shin
sang.shin@sun.com
www.javapassion.com
Java™ Technology Evangelist
Sun Microsystems, Inc.
2
3. Agenda
● What is and Why Struts?
● Struts architecture
– Controller: Focus of this presentation
– Model
– View
● Struts tag library (moved to StrutsTags
presentation)
● Internationalization
● Validation and error handling
● View selection
3
5. Jakarta Struts
● Struts is an open source Web application
framework developed as Apache Jakarta
project
– http://jakarta.apache.org/struts/
5
6. What is Struts?
● Model-View-Controller (MVC) framework
● Used for constructing web applications
using Servlets and JSPs
– Struts application is a genuine Web application that
should be able to run on any Sevlet container
including all J2EE compliant App servers
● Pattern oriented
– Singleton, composition view, delegate
– Easy to use and learn
● Includes JSP custom tag libraries
6
7. Struts allows Web Application
Developers to ...
● Fashion their JSP/Servlet web applications
using the MVC design pattern
● Leverage ready-to-usable framework objects
through xml configuration files
● Leverage built-in design patterns in the
framework
● Leverage extra features such as input
validation, internationalization
7
9. Why Struts?
● Takes much of the complexity out of building your
own MVC framework
● Encourages good design practice and modeling
● Easy to learn and use
● Feature-rich
● Many supported 3rd-party tools
● Flexible and extensible
● Large user community
● Stable and mature
● Open source 9
10. Why Struts?
● Integrates well with Java EE (J2EE)
● Good taglib support
● Works with existing web apps
● Easy to retain form state
● Unified error handling programmatically and
declaratively
● Integration with Tiles framework
● Clear delineation of responsibility makes long
term maintenance easier (more modular)
10
14. Struts: MVC-based Architecture
● Central controller mediates application flow
and delegates to appropriate handler called
Action
● Action Handlers can use model components
● Model encapsulates business logic or state
● Control forwarded back through the Controller
to the appropriate View
– The forwarding can be determined by consulting a
set of mappings in configuration file, which
provides a loose coupling between the View and
Model
14
15. Struts: MVC-based Architecture
● 3 Major Components in Struts
– Servlet controller (Controller)
– Java Server Pages or any other presentation
technology (View)
– Application Business Logic in the form of
whatever suits the application (Model)
● Struts is focused on Controller
– Struts is Model and View independent
– Struts can use any Model and View technologies
15
16. Struts: MVC-based Architecture
● Configuration file contains action
mappings
– URL to Action mappings
– Controller uses these mappings to turn HTTP
requests into application actions
– Determines forwarding/navigation
● Mapping must specify
– A request path
– Action to act upon the request
16
18. What does Controller do?
● Is the switch board of MVC architecture
● Every request goes through the controller
● Responsible for flow control (action mapping)
of the request handling
– reads configuration file to determine the flow control
18
20. Controller in Struts Framework
● Struts framework provides a built-in base
servlet
– org.apache.struts.action.ActionServlet
– Servlet mapping has to be configured in web.xml
● Struts related configuration is done through
struts-config.xml
– Action Mapping defines the mapping between
request URI of incoming requests to specific Action
class
20
21. Developer Responsibility
● Write an Action class (that is, an extension of
the Action class) for each logical request that
may be received
– override execute() method (perform() method in
Struts 1.0)
● Write the action mapping configuration file
– struts-config.xml
● Update the web application deployment
descriptor file to specify the ActionServlet
– web.xml
21
22. Controller Components in Struts
Framework
● ActionServlet (Provided by Struts)
● RequestProcessor (Struts 1.1)(Provided by Struts)
– One for each module
● Action (Provided by developer)
– Developer extends Struts-provided Action class
● Action Mapping (Specified by developer)
– Developer specifies action mapping in
struts-config.xml file
– Struts framework creates ActionMapping object and
passes it to Action object
22
24. What Does ActionServlet Do?
● Performs the role of Controller
– Process user requests
– Determine what the user is trying to achieve
according to the request
– Pull data from the model (if necessary) to be given
to the appropriate view, and
– Select the proper view to respond to the user
● Delegates most of this grunt work to Action
classes
24
25. What Does ActionServlet Do?
(Continued)
● Is responsible for initialization and clean-up
of resources
– loads the application config corresponding to the
quot;configquot; init-param's in web.xml
– goes through an enumeration of all init-param
elements, looking for those elements who's name
starts with config/ for modules
– To access the module foo, you would use a URL
like:
● http://localhost:8080/myApp/foo/someAction.do
25
27. Struts Flow (Struts 1.0)
Http://myhost/authorize.do
Server configured to pass *.do extensions to
org.apache.struts.action.ActionServlet via a
web.xml configuration file
ActionServlet object inspects the URI and tries to match it
against an ActionMapping located in the struts-config.xml file
Instance of appropriate Action class is found and it’s execute()
is called.
Action object handles the request and returns a next view.
View is identified by ActionForward objerct.
27
29. What Does RequestProcessor Do?
● processPath
– Determine the path that invoked us. This will be
used later to retrieve an ActionMapping.
● processLocale
– Select a locale for this request, if one hasn't
already been selected, and place it in the request.
● processContent
– Set the default content type (with optional
character encoding) for all responses if requested.
29
30. What Does RequestProcessor Do?
● processNoCache
– If appropriate, set the following response headers:
quot;Pragmaquot;, quot;Cache-Controlquot;, and quot;Expiresquot;.
● processPreprocess
– This is one of the quot;hooksquot; the RequestProcessor
makes available for subclasses to override. The
default implementation simply returns true. If you
subclass RequestProcessor and override
processPreprocess you should either return true
(indicating process should continue processing the
request) or false (indicating you have handled the
request and the process should return)
30
31. What Does RequestProcessor Do?
● processMapping
– Determine the ActionMapping associated with this
path.
● processRoles
– If the mapping has a role associated with it, ensure
the requesting user is has the specified role. If
they do not, raise an error and stop processing of
the request.
● processActionForm
– Instantiate (if necessary) the ActionForm
associated with this mapping (if any) and place it
into the appropriate scope. 31
32. What Does RequestProcessor Do?
● processPopulate
– Populate the ActionForm associated with this
request, if any.
● processValidate
– Perform validation (if requested) on the
ActionForm associated with this request (if any).
● processForward
– If this mapping represents a forward, forward to
the path specified by the mapping.
32
33. What Does RequestProcessor Do?
● processInclude
– If this mapping represents an include, include the
result of invoking the path in this request.
● processActionCreate
– Instantiate an instance of the class specified by
the current ActionMapping (if necessary).
● processActionPerform
– This is the point at which your action's perform() or
execute() method will be called.
33
34. What Does RequestProcessor Do?
● processForwardConfig
– Finally, the process method of the
RequestProcessor takes the ActionForward
returned by your Action class, and uses to select
the next resource (if any). Most often the
ActionForward leads to the presentation page that
renders the response.
34
36. Action Mapping in Struts Config
File
● Struts controller ActionServlet needs to
know several things about how each
request URI should be mapped to an
appropriate Action class
● These requirements are encapsulated in a
Java interface named ActionMapping
– Struts framework creates ActionMapping object
from <ActionMapping> configuration element of
struts-config.xml file
36
37. Struts Config File
(struts-config.xml)
● struts-config.xml contains three important
elements used to describe actions:
– <form-beans> contains FormBean definitions
including name and type (classname)
– <action-mapping> contains action definitions
● Use an <action> element for each action defined
– <global-forwards> contains your global forward
definitions
37
38. Struts Config File
(struts-config.xml)
● <form-beans>
– This section contains your form bean definitions.
– You use a <form-bean> element for each form
bean, which has the following important attributes:
● name: The name of the request (and session level
attribute that this form bean will be stored as)
● type: The fully-qualified Java classname of your
form bean
38
40. Struts Config File
(struts-config.xml)
● <action-mappings>
– This section contains your action definitions. You
use an <action> element for each of your actions
you would like to define.
40
41. Struts Config File
(struts-config.xml)
● <action-mappings>
– Each <action> element requires the following
attributes to be defined:
● path: The application context-relative path to the action
(URI of the request)
● type: The fully qualified java classname of your Action
class
● name: The name of your <form-bean> element to use
with this action
● input: The name of the display page when input form
validation error condition occurs
● scope: The scope in which form bean is created
● validate: Whether to perform input form validation or not 41
44. Action Mapping Config File
● <global-forwards>
– Forwards are instances of the ActionForward class
returned from an Action's execute() method
– These map logical names to specific resources
(typically JSPs)
– <forward> element has following attributes
● name: logical name of the forward
– used within execute() method of Action class to
forward to the next resource
● path: to-be-forwarded resource
● redirect: redirect (true) or forward (false)
44
48. ActionForm Bean (Form bean)
● Provided by developer
– Define an ActionForm bean (that is, a Java class
extending the ActionForm class) for the input
form
– Define it in struts-config.xml file
● <form-bean>
● name attribute of <Action> class
● Contains only property getter and property
setter methods for each field-no business
logic
● Provides standard validation mechnism
48
49. ActionForm Bean & Controller
● For each ActionForm bean defined in
servlet-config.xml file, Controller
(ActionServlet) will
– Check session scope for an instance of
ActionForm bean
● If it does not exist, controller creates one
– Call corresponding setter method of ActionForm
bean for every request parameter whose name
corresponds to the name of a property of the bean
– Pass the updated ActionForm bean object as a
parameter to execute() method of Action class
49
50. How to write ActionForm Bean
● Add just getter and setter methods for
each property of a input form
– Do not include any business logic code
● Add a standard validation method called
validate()
– Controller will call this validation
● Define a property (with associated getXxx
and setXxx methods) for each field that is
present in the input form
50
55. DynaActionForm in Struts 1.1
● Instead of creating a new ActionForm
subclass and new get/set methods for
each of your bean's properties, you can
list its properties, type, and defaults in the
Struts configuration file
– Use DanaActionForm whenever possible
● We will learn more about this in Advanced
Struts session
55
58. Action Class
● Focus on control flow
– Process client request by calling other objects
(BusinessLogic beans) inside its execute() method
– Returns an ActionForward object that identifies a
destination resource to which control should be
forwarded to
– The detination resource could be
● JSP
● Tile definition
● Velocity template
● Another Action
58
59. What is Action Class?
● Java class that does the “work” of your
application
– Handle request
– Perform business logic
● Can be simple or sophisticated
– Simple action class does handle business logic by
itself
– Sophisticated ones delegate business logic to
Model components
● Action class functions as a Facade pattern in
this case
59
60. Example Action: Logon
● Application needs to
– Authenticate a User
– Establish a User Session
– Error handling
● Develop a “LogonAction”
60
61. Developer Responsibility: Action
Class
● Extend org.jakarta.struts.action.Action
● Override
– execute() method (in Struts 1.1)
– perform() method (in Struts 1.0)
61
62. execute(..) method of Action class
(Struts 1.1 only)
● Invoked by controller
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception;
62
63. perform(..) method of Action class
(Struts 1.0 only)
● Deprecated
public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException;
63
64. execute() method of Action class
● Perform the processing required to deal with
this request
● Update the server-side objects (Scope
variables) that will be used to create the next
page of the user interface
● Return an appropriate ActionForward object
64
65. Example: Action Class
1 package submit;
2
3 import javax.servlet.http.*;
4 import org.apache.struts.action.*;
5
6 public final class SubmitAction extends Action {
7
8 public ActionForward execute(ActionMapping mapping,
9 ActionForm form,
10 HttpServletRequest request,
11 HttpServletResponse response) {
12
13 SubmitForm f = (SubmitForm) form; // get the form bean
14 // and take the last name value
15 String lastName = f.getLastName();
16 // Translate the name to upper case
17 //and save it in the request object
18 request.setAttribute(quot;lastNamequot;, lastName.toUpperCase());
19
20 // Forward control to the specified success target
21 return (mapping.findForward(quot;successquot;));
22 }
23 } 65
66. Design Guidelines of Action Class
● The controller Servlet creates only one
instance of your Action class, and uses it
for all requests
– Action class has to be in multi-threaded safe
– Use local variables (as opposed to instanace
variables)
● Make Action class a thin layer
– Use Model components for complex business logic
handling
66
67. Example 2: Action Class
1 package submit;
2 import javax.servlet.http.*;
3 import org.apache.struts.action.*;
4 public final class SubmitAction extends Action {
5 public ActionForward execute(ActionMapping mapping,
6 ActionForm form,
7 HttpServletRequest request,
8 HttpServletResponse response) {
9
10 SubmitForm f = (SubmitForm) form; // get the form bean
11 // and take the last name value
12 String lastName = f.getLastName();
13 if (lastName.startsWith(“Passion”)){
14 // Translate the name to upper case
15 //and save it in the request object
16 request.setAttribute(quot;lastNamequot;, lastName.toUpperCase());
17 // Forward control to the specified success target
18 return (mapping.findForward(quot;successquot;));
19 }
20 else{
21 return (mapping.findForward(quot;failurequot;));
22 }
23 } 67
71. Model Components
● Model divided into concepts
– Internal state of the system
– Business logic that can change that state
● Internal state of system represented by
– JavaBeans
– Enterprise JavaBeans
– POJO's
– JDO
– JDBC
– Whatever 71
73. Model Components
● JavaBeans and Scope
– Page – visible within a single JSP page, for the
lifetime of the current request
– Request – visible within a single JSP page, as
well as to any page or servlet that is included in
this page, or forwarded to by this page
– Session – visible to all JSP pages and servlets
that participate in a particular user session,
across one or more requests
– Application - visible to all JSP pages and servlets
that are part of a web application
73
74. Model Components
● JSP pages and servlets in the same web
application share the same sets of bean
collections
● Example
– Servlet code
● MyCart mycart = new MyCart(...);
● request.setAttribute(quot;cartquot;, mycart);
– JSP page
● <jsp:useBean id=quot;cartquot; scope=quot;requestquot;
● class=quot;com.mycompany.MyApp.MyCartquot;/>
74
75. Model Components in Struts
Framework
● ActionForm Bean (with a caveat)
– Please note that many people don't regard ActionForm
Bean as a Model component, instead it just represents
input data entered by a user
● SystemState Bean
– This is a conceptual term: Struts does not provide any
programming API
● BusinessLogic Bean
– This is a conceptual term: Struts does not provide any
programming API
75
77. System State Bean
● Struts does not define formal class of this
● Defines the current state
– Could be represented as a set of one or more
JavaBeans classes, whose properties define the
current state
● Example: a shopping cart system:
– Contains a bean that represents the cart being
maintained for each individual shopper
– Includes the set of items that the shopper has
currently selected for purchase
77
78. SystemState Bean
● For small scale systems or for state
information that need not be kept for a long
period of time
– a set of system state beans may contain all the
knowledge that the system ever has
● Large scale application
– System state beans may represent information
that is stored permanently in some external
database
● CustomerBean object that corresponds to a particular
row in the CUSTOMERS table
– EJB might be used 78
79. BuesinessLogic Bean
● Struts does not define formal class of this
– Can be an ordinary JavaBean
– Can be stateful or stateless EJB
● Encapsulates functional logic of an
application using method calls
● Action object should translate the HTTP
request then call BusinessLogic bean
79
80. BuesinessLogic Bean
● Ideally should be designed so that they do
not know they are being executed in a web
application environment
– should not refer any Web application objects
– enhanced reusability
80
83. View Components
● JSP files which you write for your specific
application
● Set of JSP custom tag libraries
● Resource files for internationalization
● Allows for fast creation of forms for an
application
● Works in concert with the controller Servlet
83
84. View
● ActionForward object tells Servlet controller
which JSP page is to be dispatched to
● JSP pages use ActionForm beans to get
output Model data to display
● Struts contains a series of tag libraries
– Facilitates communication between HTML designers
and developers
– Facilitates dynamic Web content
84
85. Forms and FormBean Interactions
● If the user makes an error, the application
should allow them to fix just what needs to
be changed
● With just JSP, you have to do
<input type=quot;textquot; name=quot;usernamequot;
value=quot;<%= loginBean.getUsername() >quot;/>
● With Struts, you can do
<html:text property=quot;usernamequot;/>;
85
89. Web App Deployment Descriptor
(web.xml)
● Struts application is a Web application
– Follows the same rule
– Has to have web.xml deployment descriptor
● web.xml includes:
– Configure ActionServlet instance and mapping
– Resource file as <init-param>
– servlet-config.xml file as <init-param>
– Define the Struts tag libraries
● web.xml is stored in WEB-INF/web.xml
89
93. Internationalization
● Extends basic approach of
java.util.ResourceBundle
– org.apache.struts.util.MessageResources
● Allows specification of dynamic locale key on
a per user basis
● Limited to presentation, not input
● Configure resource bundles in web.xml file
93
94. Internationalization: Developer
responsibilities
● Create resource file for a default language
● Create resource files for each language
you want to support
● Define base name of the resource bundle
in an initialization parameter
● In JSP page
– Use <html:errors/> to display locale specific error
messages
94
95. Resource files
● MyApplication.properties
– Contains the messages in the default language
for your server
– If your default language is English, you might
have an entry like this:
● prompt.hello=Hello
● MyApplication_xx.properties
– Contains the same messages in the language
whose ISO language code is quot;xxquot;
● prompt.hello=Bonjour
95
96. Example:
ApplicationResource.properties
1 errors.header=<h4>Validation Error(s)</h4><ul>
2 errors.footer=</ul><hr>
3
4 error.lastName=<li>Enter your last name
5 error.address=<li>Enter your address
6 error.sex=<li>Enter your sex
7 error.age=<li>Enter your age
96
99. Validation: Developer
responsibilities (Struts 1.0)
● Indicate you want input validation as
attributes of <action> element under
<action-mapping> in servlet-config.xml file
– validate=”true”
● Specify the JSP page that needs to be
displayed when validation fails
– input=”/errorpage.jsp”
● Override validate() method within
ActionForm class
– optional 99
100. validate() method
● Called by the controller servlet
– after the bean properties have been populated
– but before the corresponding action class's
execute() method is invoked
● Optional
– default method returns null
● Syntax
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request);
100
101. Example: validate() method
● In Login application
– Make sure both “username” and “password” are
entered
– Make sure “password” is more than 6 chracters
101
102. validate() method
● After performing validation
– if no validation error, return null
– If validation error, return ActionErrors
● Each ActionError contains error message key
into the application's MessageResources
bundle
● The controller servlet stores ActionErrors array
as a request attribute suitable for use by the
<html:errors> tag
● The controller then forwards control back to
the input form (identified by the input property
for this ActionMapping)
102
103. ActionError Class
● Mechanism used to return errors during
input validation
● Encapsulate errors
– message key used for text lookup from resource
file
● Supports parametric replacement
● ActionErrors is a collection of ActionError
103
107. Validator Framework in Struts 1.1
● Validation logic can be specified in struts-
config.xml configuration file
– Instead of writing Java code - validate() method
● We will learn about it in Advanced Struts
session
107
109. Input validation vs.
Business logic Validation
● Perform simple, prima facia validations
using the ActionForm validate() method
– Even this is optional
● Handle the quot;business logicquot; validation in
the Action class
109
110. Application Errors in Action
Class
● Capture errors from System State bean or
Business Logic bean
● Create ActionErrors object and return
● ActionServlet can take action if a certain
exception is thrown
– Can be global or Action-based
– Can either be a simple forward, or passed to a
custom error handler class
– Through defaut ExceptionHandler
110
111. CustomExceptionHandler (1.1)
● Define a custom ExceptionHandler to
execute when an Action's execute()
method throws an Exception
– Subclass
org.apache.struts.action.ExceptionHandler
– Your execute() method should process the
Exception and return an ActionForward object to
tell Struts where to forward to next
● Example
– Define one for java.lang.Exception for debugging
purpose
111
112. Custom ExceptionHandler (1.1)
● Configure your custom exception handler in
struts-config.xml
<global-exceptions>
<exception
key=quot;some.keyquot;
type=quot;java.io.IOExceptionquot;
handler=quot;com.yourcorp.ExceptionHandlerquot;/>
</global-exceptions>
● com.yourcorp.ExceptionHandler.execute()
will be called when any IOException is
thrown by an Action
112
113. CustomExceptionHandler (1.1)
● Can be either global or per action
<action ...>
<exception
key=quot;some.keyquot;
type=quot;java.io.IOExceptionquot;
handler=quot;com.yourcorp.ExceptionHandlerquot;/>
</action>
113
114. Example: Throwing an Exception
1 package hansen.playground;
2 import javax.servlet.http.*;
3 import org.apache.struts.action.*;
4 public final class SubmitAction extends Action {
5 public ActionForward execute(ActionMapping mapping,
6 ActionForm form,
7 HttpServletRequest request,
8 HttpServletResponse response) {
9
10 SubmitForm f = (SubmitForm) form; // get the form bean
11 // and take the last name value
12 String lastName = f.getLastName();
13 if (lastName.startsWith(“Passion”)){
14 // Translate the name to upper case
15 //and save it in the request object
16 request.setAttribute(quot;lastNamequot;, lastName.toUpperCase());
17 // Forward control to the specified success target
18 return (mapping.findForward(quot;successquot;));
19 }
20 else{
21 throw new WrongLastNameExcetion(lastName);
22 }
23 } 114
115. Custom ExceptionHandler (1.1)
● Different ExceptionHandler for different error
<global-exceptions>
<exception
handler=quot;com.cavaness.storefront.CustomizedExceptionHandlerquot;
key=quot;global.error.messagequot;
path=quot;/error.jspquot;
scope=quot;requestquot;
type=quot;java.lang.Exceptionquot;/>
<exception
handler=quot;com.cavaness.storefront.SecurityExceptionHandlerquot;
key=quot;security.error.messagequot;
path=quot;/login.jspquot;
scope=quot;requestquot;
type=quot;com.cavaness.storefront.SecurityExceptionquot;/>
</global-exceptions>
115
117. View Selection: Developer
responsibilities
● In struts-config file,
– Indicate “to be forwarded JSP page” (or Tiles
definition, another action, Velocity template) for
each outcome via <forward> child element of
<action> element or <global-forwards>
● In execute() method of Action class,
– Return ActionForward object which is associated
with a particular logical outcome
117
119. Example: Action Class
1 package hansen.playground;
2
3 import javax.servlet.http.*;
4 import org.apache.struts.action.*;
5
6 public final class SubmitAction extends Action {
7
8 public ActionForward execute(ActionMapping mapping,
9 ActionForm form,
10 HttpServletRequest request,
11 HttpServletResponse response) {
12
13 SubmitForm f = (SubmitForm) form; // get the form bean
14 // and take the last name value
15 String lastName = f.getLastName();
16 // Translate the name to upper case
17 //and save it in the request object
18 request.setAttribute(quot;lastNamequot;, lastName.toUpperCase());
19
20 // Forward control to the specified success target
21 return (mapping.findForward(quot;successquot;));
22 }
119
23 }