Sasidhar
JAVA SERVLETSJAVA SERVLETS
SASIDHAR
Sasidhar
2
Web Server
A web server is a network server that manages
access to files, folders and other resources over
Internet or local Intranet via HTTP
◦ Handle permissions
◦ Execute programs
◦ Keep track of directories and files
◦ Communicate with client computers
A web server consists of a computer with:
◦ a suitable operating system
◦ a suitable file system
◦ a network connection
◦ web server software – which accepts requests from
browsers such as IE and Netscape
Sasidhar
Web Server ………
 A Web server handles the HTTP protocol.
 When the Web server receives an HTTP request, it
responds with an HTTP response, such as sending back an
HTML page.
 To process a request, a Web server may respond with a
HTML page or image, send a redirect, or delegate the
dynamic response generation to some other program such
as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs
(Active Server Pages), server-side JavaScripts, or some
other server-side technology.
 such server-side programs generate a response, most often
in HTML, for viewing in a Web browser.
.
Sasidhar
Web Server ……..
Web server's delegation model is fairly simple.
When a request comes into the Web server, the
Web server simply passes the request to the
program best able to handle it.
The Web server doesn't provide any functionality
beyond simply providing an environment in which
the server-side program can execute and pass
back the generated responses.
The server-side program usually provides for itself
such functions as transaction processing, database
connectivity, and messaging.
Sasidhar
Web Server …….
While a Web server may not itself support
transactions or database connection pooling,
it may employ various strategies for fault
tolerance and scalability such as load
balancing, caching, and clustering—features
oftentimes erroneously assigned as features
reserved only for application servers
Sasidhar
6
Web Architecture
Multi-tier architecture:
◦ Application-level or middleware: has an application
server, which is used to find requested data and
services, makes them available for viewing, and carries
out transactions.
◦ Data and service level: has a variety of data and services
accessible by the application server.
Database
server
Client computers
with web
browsers
Web server
Internet
HTTP request
HTTP response
Presentation
level
Content level
Data and
service level
Application
server
Application
level
Billing
system
Sasidhar
Application Server
Application server exposes business logic to
client applications through various protocols,
including HTTP.
Application server provides access to
business logic for use by client application
programs. The application program can use
this logic just as it would call a method on an
object (or a function in the procedural
world).
Sasidhar
Application Server
Application server clients can include GUIs
(running on a PC, a Web server, or even
other application servers.
The information traveling back and forth
between an application server and its client is
not restricted to simple display markup.
 Instead, the information is program logic.
Since the logic takes the form of data and
method calls and not static HTML, the client
can employ the exposed business logic
however it wants.
Sasidhar
Application Server
In most cases, the server exposes this
business logic through a component API,
such as the EJB (Enterprise JavaBean)
component model found on J2EE (Java 2
Enterprise Edition) application servers.
 Moreover, the application server manages
its own resources that include security,
transaction processing, resource pooling, and
messaging.
Like a Web server, an application server may
also employ various scalability and fault-
tolerance techniques.
Sasidhar
Application Server
Sasidhar
Web serversWeb servers
Internet Information Server
Personal Web Server
Java Web Server
Apache Tomcat Server
Web Logic
Sasidhar
Tomcat web serverTomcat web server
 For the deployment the steps are to be followed:
1. Put the source code for the servlet in the
Server_root/webapps/ROOT/WEB-INF/classes directory
This is a standard location for servlet class files.
2. Include server_root /lib/servlet.jar somewhere in class
path so that the two packages will be included in the class
path.
3. Compile the servlet using javac filename.java
4. After compiling start the server by looking the startup.sh
script in the server root/bin directory
Sasidhar
To access the servlet, type the URL in the
browser as (if the server is on the local machine)
http://localhost :8080/servlet/passwordcheck.
Tomcat web serverTomcat web server
Sasidhar
Introduction to servletsIntroduction to servlets
Servlet runs on the server and will respond to a
request from the client either in the form of
HTML pages, dynamic pages or indeed applets.

Servers names

  • 1.
  • 2.
    Sasidhar 2 Web Server A webserver is a network server that manages access to files, folders and other resources over Internet or local Intranet via HTTP ◦ Handle permissions ◦ Execute programs ◦ Keep track of directories and files ◦ Communicate with client computers A web server consists of a computer with: ◦ a suitable operating system ◦ a suitable file system ◦ a network connection ◦ web server software – which accepts requests from browsers such as IE and Netscape
  • 3.
    Sasidhar Web Server ……… A Web server handles the HTTP protocol.  When the Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page.  To process a request, a Web server may respond with a HTML page or image, send a redirect, or delegate the dynamic response generation to some other program such as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs (Active Server Pages), server-side JavaScripts, or some other server-side technology.  such server-side programs generate a response, most often in HTML, for viewing in a Web browser. .
  • 4.
    Sasidhar Web Server …….. Webserver's delegation model is fairly simple. When a request comes into the Web server, the Web server simply passes the request to the program best able to handle it. The Web server doesn't provide any functionality beyond simply providing an environment in which the server-side program can execute and pass back the generated responses. The server-side program usually provides for itself such functions as transaction processing, database connectivity, and messaging.
  • 5.
    Sasidhar Web Server ……. Whilea Web server may not itself support transactions or database connection pooling, it may employ various strategies for fault tolerance and scalability such as load balancing, caching, and clustering—features oftentimes erroneously assigned as features reserved only for application servers
  • 6.
    Sasidhar 6 Web Architecture Multi-tier architecture: ◦Application-level or middleware: has an application server, which is used to find requested data and services, makes them available for viewing, and carries out transactions. ◦ Data and service level: has a variety of data and services accessible by the application server. Database server Client computers with web browsers Web server Internet HTTP request HTTP response Presentation level Content level Data and service level Application server Application level Billing system
  • 7.
    Sasidhar Application Server Application serverexposes business logic to client applications through various protocols, including HTTP. Application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world).
  • 8.
    Sasidhar Application Server Application serverclients can include GUIs (running on a PC, a Web server, or even other application servers. The information traveling back and forth between an application server and its client is not restricted to simple display markup.  Instead, the information is program logic. Since the logic takes the form of data and method calls and not static HTML, the client can employ the exposed business logic however it wants.
  • 9.
    Sasidhar Application Server In mostcases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Enterprise Edition) application servers.  Moreover, the application server manages its own resources that include security, transaction processing, resource pooling, and messaging. Like a Web server, an application server may also employ various scalability and fault- tolerance techniques.
  • 10.
  • 11.
    Sasidhar Web serversWeb servers InternetInformation Server Personal Web Server Java Web Server Apache Tomcat Server Web Logic
  • 12.
    Sasidhar Tomcat web serverTomcatweb server  For the deployment the steps are to be followed: 1. Put the source code for the servlet in the Server_root/webapps/ROOT/WEB-INF/classes directory This is a standard location for servlet class files. 2. Include server_root /lib/servlet.jar somewhere in class path so that the two packages will be included in the class path. 3. Compile the servlet using javac filename.java 4. After compiling start the server by looking the startup.sh script in the server root/bin directory
  • 13.
    Sasidhar To access theservlet, type the URL in the browser as (if the server is on the local machine) http://localhost :8080/servlet/passwordcheck. Tomcat web serverTomcat web server
  • 14.
    Sasidhar Introduction to servletsIntroductionto servlets Servlet runs on the server and will respond to a request from the client either in the form of HTML pages, dynamic pages or indeed applets.