You are on page 1of 24

Struts Framework

Targeted at: Entry Level Trainees

Session 03: Configuring Struts Application

© 2007, Cognizant Technology Solutions. All Rights Reserved.


The information contained herein is subject to change without notice.
C3: Protected
About the Author

Created By: Santhosh Perumal (126073)


Baskar Senguttuvan (136303)
Credential Baskar - PMP, SEI Architect
Information: Santhosh - SCJP, SCWCD, SCBCD Certified Professional
Version and STRUTS/PPT/0508/1.0
Date:

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:

This session provides a brief overview about packaging

and deploying Web applications.

4
Struts Framework Session 03:
Objective
ƒ Objective:
After completing this session, you will be able to:

» Define Web Application

» Identify elements of a Web Application

» Describe the Web application directory structure

» Explain the Web-INF directory

5
What is a Web Application?

ƒ A Web application is a collection of individual

components that once bound together, form a

complete application which can be installed

and executed by a Web container.

ƒ The Web application should have a unique

context name, which is used to identify the

Web application inside the Web container.

6
What is a Web Application? (Contd.)

ƒ The Web Application should have a


configuration file called Deployment Descriptor
named Web.xml. 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.

7
Elements of a Web Application

ƒ All Web applications do not contains the same


types of resources. In general, however Web
applications can consist one or more of the
following types of components:
» Servlets
» JSP pages
» Standard JavaBeans and utility classes
» HTML documents
» Multimedia files (images, audio, and video files.)
» Client-side applets, style sheets, and JavaScript files
» Text documents

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

ƒ Allow time for questions from participants

13
Try it Out

ƒ Create a Dynamic Web application using SDE.

14
Try it Out (Contd.)
Step 01: Create a new Project

15
Try it Out (Contd.)

Step 02: Choose Dynamic Web project

16
Try it Out (Contd.)

Step 03: Enter the project name: HelloApp

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

1. SDE 3.0 or above

20
Test Your Understanding

1. What is a Web application?


2. What is the directory structure of the Web
application?
3. What is the use of deployment descriptor in
Web application?
4. What is the use of Web-INF folder in Web
application?

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.

© 2007, Cognizant Technology Solutions. All Rights Reserved.


The information contained herein is subject to change without notice.

You might also like