Topics That We Will Explore
Topics That We Will Explore
Database
Server
Database
Server
Social Media
Different types of interacting Servers Server
The Enterprise , the Internet, and the Digital Public Space
MySQL
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
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.
• 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 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.
• 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.
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.
• 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.
• 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
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
African
Warehousing
South American Warehousing Australian Warehousing
Enterprise Computing (EC)
Service-Oriented
Computing
Internet /
Return on Investment
E-Business
Interoperability / Flexibility
Time to Market
Client-Server
Infrastructure Leverage
Computing
Mainframe
Computing
Content Management Portals Applications Legacy Applications Client Server Apps. Web Services Apps.
Oracle9iAS WebSphere App. Server Sun ONE App. Server WebLogic Server
Oracle Advanced Queuing IBM WebSphere MQ Sun ONE Message Queue WebLogic Server / Tuxedo
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
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
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
Client Server
HTTP request
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
Server
Web server
Servlet/JSP engine
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
Other Java
Servlets JavaBeans
classes
Data access
classes
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
Or
C:\apache-tomcat-9.0.52\webapps\csj
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
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.
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">
</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