The document provides an agenda for a two-day training workshop on Struts 2 and Hibernate. Day 1 covers understanding Struts 2 architecture, configuration, and features. It includes lectures on MVC design pattern, request lifecycle, and practical labs. Day 2 focuses on Hibernate, including its architecture, core classes, configuration, object states, and caching. The workshop also introduces Spring framework concepts like dependency injection and AOP. It concludes with a demo of a sample project architecture integrating Struts 2, Hibernate and Spring.
3. Workshop Agenda
Day 1
1.Understanding Struts2
2.Architecture of Struts2
3.Features of Struts2
4.Environment Setup
5.Understanding Configuration of Project
5. Understanding Struts2
•Apache Struts 2 is an elegant, extensible framework for
creating enterprise-ready Java web applications.
•The framework is designed to streamline the full
development cycle, from building, to deploying, to
maintaining applications over time.
•To make web development easier for the developers.
9. Request Life Cycle
• User sends a request to the server for requesting for
some resource (i.e pages).
• The FilterDispatcher looks at the request and then
determines the appropriate Action.
• Configured interceptors functionalities applies such as
validation, file upload etc.
10. • Selected action is executed to perform the
requested operation.
• Again, configured interceptors are applied to do any
post-processing if required.
• Finally the result is prepared by the view and returns
the result to the user.
11. Features of Struts2
• POJO forms and POJO actions
• Tag Support
• AJAX Support
• Easy Integration
12. Features continued…
• Template Support
• Plugin Support
• Profiling
• Easy to modify tags
• Promote less configuration
• View Technologies (JSP, Velocity, Freemarker,etc)
15. Create an Action Class
public class Student
{
private String fullName;
public String execute() throws Exception {
return "success";
}
public String getFullName() {
return name;
}
public void setFullName(String name) {
this.name = name;
}
}
16. Create View
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Welcome to Team Go Getters</title>
</head>
<body>
Hello,
We are glad to have <s:property value=”fullName"/> as our
student.
</body>
</html>
17. Create a launch page
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Struts2 Workshop</title>
</head>
<body>
<h1>Welcome to Team Go Getters</h1>
<form action=”welcome">
<label for="name">Please enter your name</label><br/>
<input type="text" name=”fullName"/>
<input type="submit" value=”Enroll"/>
</form>
</body>
</html>
18. Configuration Files
Struts.xml file
•Mapping between URL ,Action classes and Result Types
(View)
•Since Struts 2 requires struts.xml to be present in classes
folder.
• So create struts.xml file under the WebContent/WEB-
INF/classes folder.
23. Interceptors
• Providing preprocessing logic before the action is
called.
• Providing post-processing logic after the action is
called.
• Catching exceptions so that alternate processing can
be performed.
24. List of Interceptors
• timer
• params
• checkbox
• createSession
• logger
• fileUpload
• scope
• alias
26. Result and Result Types
• <results> tag plays the role of a view in the Struts2 MVC
framework. The action is responsible for executing the
business logic. The next step after executing the business logic
is to display the view using the <results> tag.
• Struts comes with a number of predefined result types and
whatever we've already seen that was the default result type
dispatcher, which is used to dispatch to JSP pages. Struts
allow you to use other markup languages for the view
technology to present the results and popular choices include
Velocity, Freemaker, XSLT and Tiles.
29. JDBC is going obsolete?
• Complex if it is used in large projects
• Large programming overhead
• No encapsulation
• Hard to implement MVC concept
• Query is DBMS specific
31. Hibernate: ORM
• Hibernate is a high-performance Object/Relational
persistence and query service
• Hibernate takes care of the mapping from Java classes to
database tables
• Hibernate data query and retrieval facilities
32. ORM New Generation
1. Let business code access objects rather than DB tables.
2. Hides details of SQL queries from OO logic.
3. Based on JDBC 'under the hood’
4. No need to deal with the database implementation.
33. ORM New Generation…
5. Entities based on business concepts rather than
database structure.
6. Transaction management and automatic key
generation.
7. Fast development of application.
36. Day 2 Agenda
1.Day 1 Glimpse
2.Architecture of Hibernate
3.Core classes of Hibernate
4.Hibernate configuration
5.States of Persistent Class Instances
37. 7. Overview of Caching in Hibernate
8. Understanding Spring
9. Why Spring?
10. Core Concepts of Spring
11. Spring Architecture
12. Architecture of Live Project
42. States of Persistent Class Instance
• transient: A new instance of a a persistent class which is not
associated with a Session and has no representation in the
database and no identifier value is considered transient by
Hibernate.
• persistent: You can make a transient instance persistent by
associating it with a Session. A persistent instance has a
representation in the database, an identifier value and is
associated with a Session.
• detached: Once we close the Hibernate Session, the
persistent instance will become a detached instance.
44. Understanding Spring
• Spring framework is an open source Java platform that
provides comprehensive infrastructure support for developing
robust Java applications very easily and very rapidly.
• Spring framework is an open source Java platform and it was
initially written by Rod Johnson and was first released under
the Apache 2.0 license in June 2003.
• It is simple because it just requires POJOs
45. Why Spring?
• Spring is organized in a modular fashion.
• Spring does not reinvent the wheel
• Testing an application written with Spring is simple because
environment-dependent code is moved into this framework
• Spring's web framework is a well-designed web MVC
framework
• Spring provides a consistent transaction management
interface