Professional Documents
Culture Documents
2
Icons Used
Hands on
Questions Tools Exercise
Coding Test Your
Reference
Standards Understanding
A Welcome
Try it Out Contacts
Break
3
Struts Framework Session 03:
Overview
Introduction:
4
Struts Framework Session 03:
Objective
Objective:
After completing this session, you will be able to:
5
What is a Web Application?
6
What is a Web Application? (Contd.)
7
Elements of a Web Application
8
The Web Application Directory
Structure
The resources of a Web
application are kept in a
structured hierarchy of
directories.
The directory structure is well
defined in terms of the
placement of the resources and
files. Figure shows an
imaginary Web application
named “HelloApp”.
Src: Contains java source files.
WebContent: It is the Web
module folder. It contains all
Web components like jsp, html,
and javascript files.
9
Understanding the Web-INF Directory
Every Web application must have a Web-INF directory
under its root directory.
Although it is physically located inside the document
root directory, it is not considered a part of the
document root. All files in the Web-INF directory are not
served to the clients.
This directory contains three things:
» Classes directory:
• The servlet class files and the class files needed to support the
servlets or JSP pages of this Web application go in this
directory , if they have not been included in a JAR file.
• The class files should be organized according to their
packages. At runtime, the servlet container adds this directory
to the class path for this Web application.
10
Understanding the Web-INF Directory
(Contd.)
lib directory:
» All the JAR/zip files used by the Web application,
including the third-party JAR/zip files, go in this
directory. For example, if a servlet uses JDBC to
connect to a database, the JDBC driver JAR file
should go here.
» You can also package the servlet classes in a JAR file
and keep that file in this directory.
» At runtime, the servlet container adds all the JAR/zip
files from this directory to the class path for this Web
application.
11
Understanding the Web-INF Directory
(Contd.)
Web.xml file (Also known as the deployment
descriptor):
» This file is the heart of a Web application, and every
Web application must have it.
» It contains the information needed by the servlet
container in order to run the Web application, such
as servlet declarations and mappings, properties,
authorization and security constraints, and so on.
» To ensure portability across the servlet containers,
the DTD for this XML file is standardized by Sun.
12
Q&A
13
Try it Out
14
Try it Out (Contd.)
Step 01: Create a new Project
15
Try it Out (Contd.)
16
Try it Out (Contd.)
17
Try it Out (Contd.)
Step 04: Enter content directoryname as WebContent”
and java source as “src” name. Click “Finish”.
18
Try it Out (Contd.)
Output:
19
Tools Tools
20
Test Your Understanding
21
Struts Framework Session 03:
Summary
A Web application is a collection of individual
components like jsp, html, JavaScript, and so
on.
The Web Application should have a
configuration file called Deployment Descriptor
named as Web.xml.
Every Web application must have a Web-INF
directory directly under its root directory.
Web-INF directory should have lib, classes,
and Web.xml file.
22
Struts Framework Session 03:
Source
Programming Jakarta Struts, 2nd Edition
Disclaimer: Parts of the content of this course is based on the materials available from the Web sites and
books listed above. The materials that can be accessed from linked sites are not maintained by
Cognizant Academy and we are not responsible for the contents thereof. All trademarks, service marks,
and trade names in this course are the marks of the respective owner(s).
23
You have completed the
Session 03 of
Struts Framework.