0% found this document useful (0 votes)
62 views

Topics That We Will Explore

The document outlines topics that will be explored including web application architecture, object-oriented design methodology, full-stack development, J2EE framework, Java technologies like servlets and JSP, multithreading and microservices, data analytics and Python, JavaScript and AJAX, database connectivity, different database types, web frameworks like Node/Express and Angular, and libraries like Material Design and D3.js.

Uploaded by

AJ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Topics That We Will Explore

The document outlines topics that will be explored including web application architecture, object-oriented design methodology, full-stack development, J2EE framework, Java technologies like servlets and JSP, multithreading and microservices, data analytics and Python, JavaScript and AJAX, database connectivity, different database types, web frameworks like Node/Express and Angular, and libraries like Material Design and D3.js.

Uploaded by

AJ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 135

Topics that we will explore

 Web application architecture and application servers


 Object-Oriented Design Methodology
 Full-Stack Development
 J2EE framework
 Java Servlets/JavaServer Pages (JSP)/Java Beans
 Multithreading & microservices
 Data Analytics & Python for real-time and near real-time data
streaming and processing
 JavaScript and AJAX
 Java Database Connectivity (JDBC)
 Databases: Relational, Document-Oriented, Graph
 Web frameworks: Node/Express, Angular, React
 Libraries/packages: Material Design and D3.js
Full-Stack Design & Development of the Enterprise Applications
The Enterprise , the Internet, and the Digital Public Space

It is Web-based Enterprise Application


The Enterprise , the Internet, and the Digital Public Space

Different hardware platforms but same HTTP protocol


The Enterprise , the Internet, and the Digital Public Space

dispersed elements but integrated view


The Enterprise , the Internet, and the Digital Public Space

We need to abstract the concepts to cope with complexity


The Enterprise , the Internet, and the Digital Public Space
Client Server
Side Side

A simple Client-Server view


The Enterprise , the Internet, and the Digital Public Space

Database
Server

Browser Web App


Server Server

Database
Server

Social Media
Different types of interacting Servers Server
The Enterprise , the Internet, and the Digital Public Space

MySQL

Firefox Apache Tomcat MongoDB


Node

Neo4j
Twitter
Different platforms
The Enterprise , the Internet, and the Digital Public Space
• HTTP
• HTTP
• HTML
• Servlets
• CSS
• JSP
• XML
• Python
• AJAX
• JavaScript
• JavaScript

MySQL

Firefox Apache Tomcat

MongoDB

Twitter
Different technologies
Server Types
● Web servers.
● Application servers.
● Database servers.
● Mail servers.
● Media servers.
● Authentication servers.
Real World Server Installations
Not one server, but a cluster of multiple machines working
together.

● Server Farm
● Load Balancers
● Failover Redundancy
● Server Racks
● Data Centers
● Cloud Services
Working in Web Development
Uniform Resource Locators
Uniform Resource Locators (URL) allow clients to request particular resources (files)
from the server.

URL’s consist of two required components:

1. the protocol used to connect and

2. the domain (or IP address) to connect to.


Uniform Resource Locators (optional)

Optional components of the URL are:

• the path (which identifies a file or directory to access on that server),

• the port to connect to,

• a query string, and

• a fragment identifier
Port (URL)
• A port is a type of software connection point used by the underlying TCP/IP
protocol and the connecting computer.

• Although the port attribute is not commonly used in production sites, it can be
used to route requests to a test server, to perform a stress test, or even to
circumvent Internet filters.

• If no port is specified, the protocol determines which port to use. For instance,
port 80 is the default port for web-related HTTP requests.

• Syntax is to add a colon after the domain, then specify an integer port number.
http://funwebdev.com:8080/ would connect on port 8080
Path (URL)
• The path is an important concept to anyone who has ever used a computer file
system.

• The root of a web server corresponds to a folder somewhere on that server.On


many Linux servers that path is /var/www/html/ or something similar (for
Windows it is often /inetpub/wwwroot/).

• The path is optional. However, when requesting a folder or the top-level page of
a domain, the web server will decide which file to send you.
Query String (URL)

Query strings are a critical way of passing information, such as user form input, from
the client to the server.

• In URLs, they are encoded as key-value pairs delimited by & symbols and preceded
by the ? Symbol

• An example query string for passing name and password is shown in Figure 2.11
Fragment (URL)
• The last part of a URL is the optional fragment.

• This is used as a way of requesting a portion of a page.

• Browsers will see the fragment in the URL (denoted by #), seek out the fragment
tag anchor in the HTML, and scroll the website down to it.

• “back to top” links are a common use of fragments.


Hypertext Transfer Protocol

• HTTP is an essential part of the web.

• HTTP establishes a TCP connection


on port 80 (by default). The server
waits for the request, and then
responds with a
– Headers,
– Response code,
– an optional message (which can
include files)
HTTP Headers

Headers are sent in the request from the client and received in the response from
the server. Headers are one of the most powerful aspects of HTTP and unfortunately,
few developers spend any time learning about them.

• Request headers include data about the client machine


– Host, User-Agent, Cache settings and more

• Response headers have information about the server answering the request and
the data being sent
– Server, Last Modified, Content Type, Encoding,
HTTP Request Methods
• The most common requests are the GET and POST request, along with the HEAD
request

• In Chapter 13 you will make use of the PUT and DELETE requests when creating
an API in Node.

• Other HTTP verbs such as CONNECT, TRACE, and OPTIONS are less commonly
used and are not covered in the book.
GET Request
• The most common type of HTTP request is the GET request.

• One is asking for a resource located at a specified URL to be retrieved.

• Whenever you click on a link, type in a URL in your browser, or click on a


bookmark, you are usually making a GET request.

• Data can be transmitted through a GET request, with a query string


POST Request
• The other common request method is the POST request.

• This method is normally used to transmit data to the server using an HTML form
Response Codes
• Response codes are integer values returned by the server as part of the response
header.

• These codes describe the state of the request, including whether it was
successful, had errors, requires permission, and more.

• The codes use the first digit to indicate the category of response.
– 2## codes are for successful responses,
– 3## are for redirection-related responses,
– 4## codes are client errors, while
– 5## codes are server errors.
HTTP Response Codes (Table 2.1 edited)

Code Description
200: OK The request was successful.

301: Moved Permanently Tells the client that the requested resource has permanently moved.

304: Not Modified If the client requested a resource with appropriate Cache-Control headers, the
response might say that the resource on the server is no newer than the one in
the client cache.
401: Unauthorized Some web resources are protected and require the user to provide credentials
to access the resource.
404: Not found 404 codes are one of the only ones known to web users. Many browsers will
display an HTML page with the 404 code to them when the requested resource
was not found.
414: Request URI too long A 414 response code likely means too much data is likely trying to be
submitted via the URL.
500: Internal server error This error provides almost no information to the client except to say the server
has encountered an error.
Web Browsers
• The user experience for a website is unlike the user experience for traditional
desktop software.

• Users do not download software; they visit a URL, which results in a web page
being displayed.

• Although a typical web developer might not build a browser, or develop a plugin,
they must understand the browser’s crucial role in web development.
Web Browsers (Fetching a web page)
• Seeing a single web page is facilitated by the browser, which
– requests the initial HTML page, then
– parses the returned HTML to find all the resources referenced from within it
(like images, style sheets, and scripts).

• Only when all the files have been retrieved is the page fully loaded for the user

• A single web page can reference dozens of files and requires many HTTP requests
and responses.
Fetching a web page diagram
Browser Rendering
• The algorithms within browsers to download, parse, layout, fetch assets, and
create the final interactive page for the user are commonly referred to
collectively as the rendering of the page
Web Servers
• A web server is, at a fundamental level, nothing more than a
computer that responds to HTTP requests.
• Real-world websites typically have many web servers
configured together in web farms.
• Regardless of the physical characteristics of the server, one
must choose an application stack to run a website. This
application stack will include
– an operating system,
– web server software,
– a database, and
– a scripting language to process dynamic requests.
Software Stacks

• Quite few in the software industry, just to name a few of these ….


• MEAN stack refers to MongoDB database, Express application framework,
the JavaScript Angular framework, and Node.js as the web server and
execution environment.
• MERN stack refers to MongoDB database, Express application framework,
the JavaScript React framework, and Node.js as the web server and
execution environment.
• Microsoft WISA software stack refers to Windows operating system, IIS
web server, SQL Server database, and the ASP.NET server-side
development technologies.
• Another web development stack that is growing in popularity is the so-
called JAM stack, which refers to JavaScript, APIs, and markup.
Most popular
Programming Languages, Technologies
and Frameworks for the development of
enterprise applications
• We will utilize
top 7 excluding
Bash/shell
• We will utilize a
number of DB
Engines
The JavaScript Fatigue
We want to discuss the design and
development principles of the enterprise
web-based applications
What features or aspects of the
technology most important to you for
software application development?
- Speed
- Reusability
- ilities (flexibility, adaptability, reliability, etc.) family
- Standards
- Cross-platforms
- Etc.
Technologies discussed in the Class
•JavaScript/ AJAX
•Servlet/JSP
•Node/Express/Angular/React
•HTML/HTTP/XML
•Python
•SQL/NoSQL/Cypher
Software Engineering Body of Knowledge
BOK

Software
Computing Software Software
Product
Fundamentals Management Domains
Engineering
Algorithms and Requirements Project Process Artificial
Data Structures Engineering Management Intelligence
Computer Software Risk Database
Architecture Design Management Systems
Mathematical Software Quality Human-Computer
Foundations Coding Management Interaction
Operating Numerical &
Software Configuration
Systems Symbolic Comp.
Testing Management
Programming Computer
Software Dev. Process
Languages Simulation
Ops& Maint Management
Real-Time
Acquisition
Systems
Management
Overview
 What is an enterprise?
 What constitutes an enterprise?
 What is enterprise computing (EC)?
 What is the nature of an EC environment?
 What makes a good enterprise application?
An Enterprise is...
any organization with set of goals

U.S. Engineering
Asian Warehousing
Finance
Asian Engineering
North American Headquarters
Warehousing
Sales & Marketing

Mexican Asian Manufacturing


Manufacturing

African
Warehousing
South American Warehousing Australian Warehousing
Enterprise Computing (EC)

“Enterprise computing involves the development,


deployment and maintenance of the information systems
required for survival and success in today’s business
climate.”

Yen-Ping Shan & Ralph H. Earle,


Enterprise Computing with Objects,
Addison-Wesley, 1998.
Evolution of The Enterprise Computing
1980’s 1990’s 2000’s

Service-Oriented
Computing

Internet /
Return on Investment
E-Business
Interoperability / Flexibility
Time to Market
Client-Server
Infrastructure Leverage
Computing

Mainframe
Computing

• Packaged & Custom • Client-Server • Enterprise Web


Mainframe Applications Applications Applications & Suites

• Top-Down, Procedural • Object-Oriented • Web Services &


Development Development Software Components

Period • Centralized Computing • Enterprise-Centric • Next-Generation


Characteristics Models Computing Integrations

• Non-Distributed Solutions • Internet Proliferation • Real-Time Application


Assembly
• Emerging PC-Based • E-Commerce
Technologies Applications • Rapid Deployment &
Management
EC Environment
 computers are typically dispersed over a wide area
 old (“legacy”) applications need to be
used/maintained
 very large databases
 (e.g., tens of databases (DB), hundreds of tables per DB,
thousands to millions of records per table)
 hundreds to thousands/millions of clients
 heterogeneous
 computers, client devices, networks, applications
 constantly-changing business requirements
 mission-critical applications
 requires reliability and performance
Enterprise Application Qualities
 extensible -- allows for future changes with minimal impact
 scalable -- gracefully handles expansion/contraction in number of clients
 usable/reliable -- functions as advertised, including error-handling
 available -- can be used whenever needed
 configurable -- can be adapted to diverse environments
 deployable -- can be easily distributed to users
 durable -- necessary information lasts/persists over time
 efficient/responsive -- uses minimal resources/performs well for clients
 unobtrusive -- doesn’t get in the way of getting things done
 secure -- only authorized clients can access
 reusable -- many parts can be reused rather than re-created
 maintainable -- can be fixed with minimal impact
 timely -- is ready to use productively during window of opportunity
The Impact of Standards

Content Management Portals Applications Legacy Applications Client Server Apps. Web Services Apps.

Enterprise Web Applications Development, Deployment, & Management


(Management of Portals, Web Services, Content, Applications & Web Initiatives)

Oracle9iAS WebSphere App. Server Sun ONE App. Server WebLogic Server

Oracle E-Commerce WebSphere Commerce PE — WebLogic Portal

Oracle Workflow MQSeries Workflow


Sun ONE Integration
WebLogic Integration
Oracle9iAS CrossWorlds / WebSphere Server, EAI Edition
Integration / InterConnect MQ Integrator Broker

Oracle Advanced Queuing IBM WebSphere MQ Sun ONE Message Queue WebLogic Server / Tuxedo

Oracle 9i Database DB/2 Database — —


The J2EE Platform, Architecture
Evolution To Web Services
TCP/IP: universal protocol
HTML: universal presentation
XML: universal description

Connectivity Presentation Programmability

Key success factors:


Browse
•Simplicity the Web

Program
•Standards the Web
The Web Architecture
User
Web Site:
Applications
Page HTML

Data XML
JSP/
Content Servlet

Devices
Web Site:
Applications
Tiers, Tools and Services
The Enterprise

Mainframe
Application
Directory
Presentation services
services RDBMS
Email and
messaging
File system
Distributed transactions
and query processing across
multiple data stores
1 st & 2nd Generation Web Apps

File DB In-house
systems
File

Web Server Web Server

Browser Browser
1-1 correspondence “Dynamic Pages”
of page to file
3rd Generation Web In-house
systems
Accessing another Web
Web
site today = HTML service
site
File
“screen scraping” Web
DB
Web
or “your architect service
site
calls my architect”
Web
Web
service Web Server

“The Firewall”
site
Tomorrow, external
Web sites become
building blocks using
XML
•Web Services
•Megaservices
Browser
“Dynamic Pages”
Examples of Web Services

Location Maps, routing, nearby


Services locations…
Order tracking, supply
Shopping
Services chain, auctions,
coupons…
Information Headlines, weather,
Services horoscopes, TV times…

Communication Email, instant


Services messages…
Required Tools for Servlet/JSP web app
 Java
 http://www.oracle.com/technetwork/java/javase/do
wnloads/index.html

 Apache Tomcat
 http://tomcat.apache.org/whichversion.html
Required Tools for JavaScript web app
 Web Framework/Library
 Angular
 React
 Vue
 Etc.

 Node.js/Express
What is an Enterprise
Application?
 Software applications that integrate and
support all aspects of operations of an
enterprise/ business.
Challenges for the Enterprise Application
 Challenges:
 Heterogeneous data sources
 Diverse user base
 Multiple platforms/ products/ vendors/
technologies
 High level of integration and consistency
Overview of J2EE
 “Enterprise” APIs were packaged
together as Java 2, Enterprise Edition
 The standard JDK (javac, java, etc.)
was called Java 2, Standard Edition
 J2EE includes the entire set of APIs, but
may be used in smaller pieces.
J2EE overview (cont.)
 Java Servlets
 a simple, consistent mechanism for extending the
functionality of a web server.
 JavaServer Pages
 a simplified, fast way to create dynamic web
content.
 server and platform independent.
 Enterprise JavaBeans Architecture
 create, deploy and manage cross- platform,
component-based enterprise applications
J2EE overview (cont.)
 JDBC
 a uniform interface to a wide range of relational
databases.
 JavaMail
 a platform independent and protocol independent
framework to build Java- based mail and
messaging applications.
 Java Naming and Directory Interface
(JNDI)
 allows unified access to multiple naming and
directory services across the enterprise.
J2EE Overview (cont.)
 Java Message Service (JMS)
 a standard Java API for reliable enterprise
messaging services. (point-to-point and
publish/subscribe)
 Java Transaction API (JTA)
 a high-level transaction management specification
intended for resource managers and transactional
applications in distributed transaction systems.
 Java Transaction Service (JTS)
 provides open, standard access to transaction
resources.
J2EE Overview (cont.)
 Java Interface Definition Language (IDL)
 provides interoperability with CORBA, the industry
standard for heterogeneous computing.
 RMI-IIOP
 an implementation of the Java RMI API over the
OMG's industry-standard Internet Inter-Orb
Protocol (IIOP).
 J2EE Connector
 a standard architecture for connecting the J2EE
platform to heterogeneous Enterprise Information
Systems.
Java and XML
 Java and XML are integrated
 Java API for XML Messaging (JAXM)
 Java API for XML Parsing (JAXP)
 Java API for XML Data Binding (JAXB)
 JavaTM API for XML-based RPC (JAX-RPC)

 Java an dXML
 http://docs.oracle.com/javase/tutorial/jaxp/
 XML page:
 http://www.w3.org/XML//
Java and XML
Java and XML
Components of a web application

Server computer
Client computer

Internet
connection

Web browser Web server


Database server
The components of a web application
 Web applications are a type of client/server application.
 In a client/server application, a user at a client computer accesses
an application at a server computer.
 For a web application, the client and server computers are
connected via the Internet or an intranet.
 In a web application, the web browser provides the user interface
for the application.
 A web application runs on the server computer under the control
of web server software.
 For most web applications, the server computer also runs a
database management system (DBMS).
How a web server processes static web pages

Client Server

HTTP request

Browser Web server HTML file

HTTP response
How static web pages work
 Hypertext Markup Language, or HTML, is the language that the
web browser converts into the web pages of a web application.
 A static web page is an HTML document that’s stored in a file
and does not change in response to user input.
 Hypertext Transfer Protocol, or HTTP, is the protocol that web
browsers and web servers use to communicate.
 A web browser requests a page from a web server by sending the
server a message known as an HTTP request. For a static web
page, the HTTP request includes the name of the HTML file
that’s requested.
 A web server replies to an HTTP request by sending a message
known as an HTTP response back to the browser. For a static web
page, the HTTP response includes the HTML document.
How a web server processes dynamic web pages

Client Server

HTTP request
Web
Browser Web server
application
HTTP response
How dynamic web pages work
 A dynamic web page is an HTML document that’s generated by a
web application. Often, the web page changes according to
parameters that are sent to the web application by the web
browser.
 When a web server receives a request for a dynamic web page, the
server passes the request to the web application. Then, the
application generates a response, which is usually an HTML
document, and returns it to the web server.
 The web server, in turn, wraps the generated HTML document in
an HTTP response and sends it back to the browser.
 The browser doesn’t know or care whether the HTML was
retrieved from a static HTML file or was dynamically generated
by the web application. Either way, the browser displays the
HTML document that is returned.
The components of a Java web application
Client

Browser

HTTP request HTTP response

Server

Web server

Servlet/JSP engine

Java Development Kit (JDK)

Database server
Components needed for Java web application
 Java web applications consist of JavaServer Pages and servlets.
 A servlet/JSP engine, or servlet/JSP container, is the software
that allows the web server to work with servlets and JSPs.
 The Java Enterprise Edition (Java EE), specification describes
how web servers can interact with servlet/JSP engines.
 For a servlet/JSP engine to work, it must have access to Java’s
Java Development Kit (JDK), which comes as part of the Java
Standard Edition (Java SE).
 Among other things, the JDK contains the core Java class
libraries, the Java compiler, and the Java Runtime Environment
(JRE).
 Java web applications that use Enterprise JavaBeans (EJBs)
require an additional server component known as an EJB server,
or EJB container.
 Who use the Java-based technologies
for their websites?
 Who use the Java-based technologies
for their websites?
The architecture for a typical Java web application
Presentation layer

HTML files JSP files

Business rules layer

Other Java
Servlets JavaBeans
classes

Data access layer

Data access
classes

Database Text files Binary files XML files


The architecture for a typical Java web application
(continued)
 The presentation layer for a typical Java web application consists
of HTML pages and JSPs.
 The business rules layer for a typical Java web application
consists of servlets. These servlets may call other Java classes
including a special type of Java class known as a JavaBean. In
chapters 9 and 10, you’ll learn how to use several special types of
tags within a JSP to work with JavaBeans.
 The data access layer for a typical Java web application consists
of classes that read and write data that’s stored on the server’s
disk drive.
 For a serious web application, the data is usually stored in a
relational database. However, it may also be stored in binary
files, in text files, or in Extensible Markup Language (or XML)
files.
Free Servlet and JSP Engines
 Apache Tomcat
 http://tomcat.apache.org/
Free Servlet and JSP Engines
Apache Tomcat
The subdirectories
Directory Description
bin Files for working with Tomcat such as the startup and
shutdown batch files.
conf Files for configuring Tomcat such as server.xml,
context.xml, and web.xml.
lib JAR files that contain classes that are available to all web
applications. As a result, you can put any JAR files you
want to make available to all web applications in this
directory.
logs Log files.
temp Temporary files used by the JVM.
webapps The directories and files for the web applications.
work The source code and class files for the servlets that Tomcat
generates for the JSPs.
The files
File Description
RELEASE-NOTES General information about the current release
of Tomcat.
running.txt Instructions for installing, starting, and
stopping Tomcat.
The JAR files that need to be available to the JRE
servlet-api.jar
jsp-api.jar
el-api.jar
tomcat-dbcp.jar

Description
 The directory that holds the files for Tomcat is known as the
Tomcat home directory. By default, this directory is named
apache-tomcat-7.0.X, but you can rename it to tomcat.
 The Java Archive (JAR) files shown above contain the Java
classes that need to be available to the JDK and JRE when you
develop servlets and JSPs. By copying these JAR files from
Tomcat’s lib subdirectory to the JDK’s jre\lib\ext subdirectory,
you make the classes available to the JDK and JRE.
Apache Tomcat – env setup
Apache Tomcat
Apache Tomcat
Apache Tomcat
Apache Tomcat
Apache Tomcat
Apache Tomcat
The components of an HTTP URL

HTTP URLs that you can use to test Tomcat


http://localhost:8080/
http://localhost:8080/examples/servlets/
http://localhost:8080/examples/jsp/

How to view a web page via an HTTP URL


1. Start Tomcat.
2. Start your web browser.
3. Type an HTTP URL into your web browser and press Enter.
The Internet Explorer’s error page
Tomcat’s default 404 error page
How to solve common Tomcat problems
 If the browser displays an error page that says “The page cannot be
displayed,” the HTTP request isn’t connecting with a web server.
To solve this problem, make sure that the Tomcat engine is
running, and make sure that you’ve entered a valid host name and
port number.
 If the browser displays a 404 error page, Tomcat is receiving the
HTTP request, but it can’t find the requested resource. To solve
this problem, make sure that you’ve entered the path and filename
of the URL correctly.
Compiling and Invoking Servlets
 Set your CLASSPATH
 Servlet JAR file (e.g., install_dir/lib/servlet-api.jar).
 Top of your package hierarchy
 Put your servlet classes in proper location
 Locations vary from server to server. E.g.,
 tomcat_install_dir/webapps/ROOT/WEB-INF/classes
See http://archive.coreservlets.com/Using-Tomcat.html
 Invoke your servlets
 http://host/servlet/ServletName
 Custom URL-to-servlet mapping (via web.xml)
Compiling and Invoking Servlet (apache-tomcat-
9.0.52; Class Setup)

 Place your source code in


 C:\csj

Or
 C:\apache-tomcat-9.0.52\webapps\csj

 CLASSPATH already set


 Start DOS; type "javac HelloWorld.java"
 Place HelloWorld.class in servlet directory
 C:\apache-tomcat-9.0.52\webapps\csj\WEB-INF\classes

OR
 C:\apache-tomcat-9.0.52\webapps\ROOT\WEB-

INF\classes
Compiling and Invoking Servlet
(Tomcat 9.0.52; Class Setup)
Compiling and Invoking Servlet
(Tomcat; Class Setup)
Compiling and Invoking Servlet
(Tomcat; Class Setup)
 You can create your own context “subdirectory” under the root
directory for tomcat:
 C:\apache-tomcat-9.0.52\webapps\csj

 Keep all of your homeworks, projects, etc. under


 C:\apache-tomcat-9.0.52\webapps\csj

 Start server
 From MS-DOS cmd type startup.bat and hit enter

 Invoke servlet
 http://localhost/csj/HelloWorld
Web.xml to Invoke Servlet
Compiling and Invoking Servlet
How to add a username and password for the
manager role
 Open the tomcat-users.xml file that’s in Tomcat’s conf directory
in a text editor.
 Add a role element that defines the manager role.
 Add a user element that provides a username and password for the
manager role.
 If Tomcat is running when you add users to the tomcat-users.xml
file, you need to restart Tomcat after you close the file so Tomcat
will recognize the changes.

The tomcat-users.xml file


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<user username="admin" password="sesame" roles="manager"/>
</tomcat-users>
How to start Tomcat's Web Application Manager
 To start the Web Application Manager, start a web browser and go
to http://localhost/manager/html.
 Tomcat will prompt you for a username and password. If you
supply a valid username and password for the manager role, you
will be able to view the Web Application Manager.

The Authentication Required dialog box


How to use Tomcat's Web Application Manager
 To reload all of the classes for an application, click on the Reload
link for the application.
 To stop an application, click on the Stop link for the application.
 To start an application, click on the Start link for the application.
 To undeploy an application, click on the Undeploy link for the
application. This deletes all files for the web application from
Tomcat’s server.
The server.xml file
How to change the port that’s used by Tomcat
1. Use the Windows Explorer to navigate to Tomcat’s conf directory
and open the server.xml file in a text editor.
2. Replace all instances of the current port, which is 8080 by default,
to a four-digit number that’s greater than 1024 or to 80. To do
this, you may want to use the Find and Replace feature of your
text editor.
3. Save the changes to the server.xml file.
4. Stop and restart Tomcat.

Notes
 If you have a port conflict with another application, you can
change the 8080 default to a 4-digit number greater than 1024.
 If you don’t enter a port when you specify a URL, your browser
will use port 80. So if you change Tomcat’s default port to 80,
you don’t need to specify a port when entering a URL.
The standard directories and files for a web
application
 The top-level directory for a web application is known as its root
directory.
 A Java web application is a hierarchy of directories and files in a
standard layout defined by the Java EE specification. All Java web
applications must use the root, \WEB-INF, and
\WEB-INF\classes directories.
 To make classes within a JAR file available to more than one web
application, you can put the JAR file in Tomcat’s lib directory.
A web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Murach's Servlets and JSP:


Music Store site</display-name>

<description>The Music Store web site that's described


in Murach's Java Servlets and JSP (second
edition)</description>

<!-- Enable servlet mapping -->


<servlet>
<servlet-name>AddToEmailListServlet</servlet-name>
<servlet-class>music.email.AddToEmailListServlet
</servlet-class>
</servlet>
A web.xml file (continued)
<!-- Map servlets to URL patterns -->
<servlet-mapping>
<servlet-name>AddToEmailListServlet</servlet-name>
<url-pattern>/email/addToEmailList</url-pattern>
</servlet-mapping>

<!-- Specify index pages -->


<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>

</web-app>

Description
 Every web application requires a web.xml file in the WEB-INF
directory. This file is known as the deployment descriptor for the
web application. The highlighted code is required in the file.
What the web.xml file can do
 Enable servlet mapping so you can call a servlet using any URL or
URL pattern.
 Define initialization parameters for a servlet or the entire
application.
 Define error pages for an entire application.
 Provide security constraints to restrict access to certain web pages
and servlets.
The context.xml file
How to turn on servlet reloading
1. Use a text editor to open the context.xml file in Tomcat’s conf
directory.
2. Add the reloadable attribute to the Context element and set this
attribute to true like this:
<Context reloadable="true">
3. Save the changes to the context.xml file
4. If necessary, stop and restart Tomcat.
Servlet reloading
 If servlet reloading isn’t on, which is the default setting, you have
to stop and restart Tomcat each time that you change one of the
classes that’s in memory.
 If you turn servlet reloading on, Tomcat checks the modification
dates of the classes in memory and automatically reloads the ones
that have changed. Although this is useful in development, it can
cause performance problems in a production environment.
 The context.xml file is an XML file that controls how the Tomcat
engine is configured. Tomcat reads this file every time it starts to
configure itself. You can use a text editor to edit this file. Then,
you can stop and restart Tomcat to put the changes into effect.
 This is a global setting that affects all web applications running on
this instance of Tomcat.
 What is in the configuration directory?
 What is in the csj directory?
 What is in the csj/WEB-INF directory?
 Finally:
 Please finish the installation and testing for
Tomcat
 Please compile and run HelloWorld servlet
example
 Make sure env-setup-for-tomcat is
executed before you start running tomcat
and compiling your servelts

You might also like