In this Java Hibernate Training session, you will learn Integrating Struts with Hibernate. Topics covered in this session are:
• Struts 2
• Struts Action Class
• Validation
• Control Tags
• Data Tags
For more information, visit this link:
https://www.mindsmapped.com/courses/software-development/learn-hibernate-fundamentals-from-scratch/
3. Page 2Classification: Restricted
Struts framework
• The struts 2 framework is used to develop MVC-based
web application.
• The struts framework was initially created by Craig
McClanahan and donated to Apache Foundation in May,
2000 and Struts 1.0 was released in June 2001.
• Craig R. McClanahan is a programmer and original
author of the Apache Struts framework for building web
applications. He was part of the expert group that
defined the servlet 2.2, 2.3 and JSP 1.1, 1.2
specifications. He is also the architect of Tomcat's servlet
container Catalina.
4. Page 3Classification: Restricted
Struts 2 Framework
• The Struts 2 framework is used to develop MVC (Model View Controller)
based web applications. Struts 2 is the combination of webwork
framework of opensymphony and struts 1.
struts2 = webwork + struts1
5. Page 4Classification: Restricted
Struts 2 Features
• Configurable MVC components
• POJO based actions
• AJAX support
• Integration support – with Hibernate, Spring etc
• Various Result Types – JSP, Freemarker, Velocity etc
• Various Tag support
• Theme and Template support
6. Page 5Classification: Restricted
Web Application Architecture - Evolution
• Model 1 Architecture
pag
e 5
• Navigation control is decentralized
• Time Consuming
• Hard to extend
7. Page 6Classification: Restricted
Web Application Architecture - Evolution
• Model 2 Architecture
pag
e 6
• Navigation control is centralized Now only controller contains the logic to determine the next
page.
• Easy to maintain, extend and test
• Better separation of concerns
• (SOLID principles: OOP: Single Responsibility Principle)
9. Page 8Classification: Restricted
• JSP: Server Page technology… like ASP, BSP…
• Page is dynamically built on the server…
• Presentation logic goes into the server.
• Limitation:
• As number of clients increases, the server has more work to do. (Controller
logic + Presentation Logic)
• If your web app is responsive/adaptive, it has much more work to do on the
presentation logic.. It has to check the form factor of the device that is
trying to access the web page…
• Solution:
• Move the presentation logic to the client… JS libraries (Angular) + CSS (LESS,
SASS)..
• RESTful architecture.
14. Page 13Classification: Restricted
Struts 2 interceptors
• Interceptors are conceptually the same as servlet filters or the JDKs Proxy
class. Interceptors allow for crosscutting functionality to be implemented
separately from the action as well as the framework. You can achieve the
following using interceptors:
• Providing preprocessing logic before the action is called.
• Providing postprocessing logic after the action is called.
• Catching exceptions so that alternate processing can be performed.
15. Page 14Classification: Restricted
17-08-2018 14
Interceptors
Can execute code before and after execution
Are thread-safe
Can be used for
Validation
Pre populating fields
Double-submit prevention
Session control
Authentication
Type conversion
16. Page 15Classification: Restricted
Some Struts 2 Interceptors
alias Allows parameters to have different name aliases across requests.
checkbox Assists in managing check boxes by adding a parameter value of
false for check boxes that are not checked.
conversionError Places error information from converting strings to parameter
types into the action's field errors.
createSession Automatically creates an HTTP session if one does not already
exist.
debugging Provides several different debugging screens to the developer.
execAndWait Sends the user to an intermediary waiting page while the action
executes in the background.
exception Maps exceptions that are thrown from an action to a result,
allowing automatic exception handling via redirection.
fileUpload Facilitates easy file uploading.
i18n Keeps track of the selected locale during a user's session.
logger Provides simple logging by outputting the name of the action being
executed.