Web Servers (Structure and Deployment of Application) Unit-V

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

Unit-V

Web Servers(Structure and


Deployment of Application)

Introduction
A web server is a program that produces webpages in response to
requests from a web browser.
Web servers run the programs in response to user requests and return the
dynamic results to the web browsers.
Web servers can perform complex tasks like
Accepting a client request including arguments.
Running a program on the arguments and return results in the form of
HTML document.
Web application is a application running on a web server which allows
users for accessing through a client runs from a web browser.
Web browsers initiate network communications with servers by sending
them URLs.
All the communications between a web client and a web server use the
standard web protocol, HTTP i.e. in the form of HTTP commands.
2

Web Server: TOMCAT


Setting up a New Web Application:
To set up a new web application( or Servlet) with Tomcat, you need to add a directory
under the webapps dir and create a subdirectory called WEB-INF.
WEB-INF needs to contain a web.xml file ( a Tomcat/servlet configuration file).
Make sure you are consistent in the way you use upper case and lower case in your
directory names.
The easiest thing to do is to make a copy of the webdav directory and give it a new name.
After the WEB-INF directory is created, create a subdirectory under it called classes.
Your Java Package/classes will go under this directory.

Web Server: TOMCAT


Web application Development using Tomcat(Structure of Web Application)
A web application is a collection of static HTML pages, dynamic JSPs and
Servlet classes.
User Interfaces
(Collects Inputs from user)

.html
files
.jsp
files

Validates Inputs dynamically


.class
files

Web server: links all the files,


processes, and Produces results

Web application is defined as a hierarchy of directories and files in a standard


layout.
This hierarchy can be accessed in Two ways:
Unpacked each directory and file exists in the file system separately.
Packed form like Web Archive or RAR file. It is useful for distribution
of the web application and executing at various locations
4

Structure of Web Application

Structure of Web Application


Application Root Directory Root directory of the Web Application.
The name of this directory is named by the
developer - for example the default context we
created for this module was called "student".All JSP,
HTML and image files are stored here. Typically,
there would be an index.html or index.jsp file in this
directory.
The "other directories" could be, for example,
"images" (containing gifs and jpgs for the html
pages and servlets used in the Application), "style"
(containing the .css or other style files used) or
simply subdirectories of HTML or JSP pages.

Structure of Web Application


/WEB-INF- This directory contains all resources related to the
application that are not in the document root of the application.
It should be noted that the WEB-INF directory is not part of the
public document (ie. paths beginning in
http://localhost:8080/student/WEB-INF cannot be viewed in a
browser) and no files contained in this directory can be served
directly to the client.
The WEB-INF directory also contains theWeb Application
Deployment Descriptor.
/WEB-INF/classes- contains the application Java Servlets, class
files, JavaBeans and utility classes.
/WEB-INF/lib- The lib directory contains the Java ARchive (JAR)
files (or ZIP) that the web application depends upon. For
example, this directory might contain a JDBC Database
Connectivity driver in JAR or Zip format.
/WEB-INF/web.xml- The deployment descriptor is an XML file
named web.xml and forms the heart of the Web Application.

Servlets

A Servlet is a program designed to process a client request.

Servlets are simple java programs that run on servers.

Servlets are commonly used with HTTP, hence the name HTTP Servlet

Servlets make use of Java standard extension classes in packages javax.servlet and
javax.servlet.http
Uses of Servlets:
Processes and stores data submitted by HTML form
Useful for retrieving and updating databases
Servlets working is based on Request-Response
Used in Cookies and session tracking
Cookies are a message given to a Web browser by a Web server. The browser
stores the message in a text file.
Session tracking keeps track of all previously accessed web pages
8

How Servlet Works?

How Servlet Works?

Client makes a request for some servlet using Web Browser

The Web Browser then sends the request to Web Server. The Web Server finds
the requested servlet

The obtained servlet gathers the relevant information by clients request and
builds a Web Page

The Web page is displayed by clients request

10

Deployment of Servlets

Writing the servlets is best choice for server side programming

Servlets need a special environment for execution i.e., Tomcat, a servlet


container & open-source product is recommended which contains class
libraries, documentation and runtime support which is useful for executing and
testing the servlets.

For execution of servlets, following software must be installed


JDK: As servlets are basically java files, JDK must be installed
Tomcat: servlet can be executed

11

JDSK
The Java Development Standard Edition Kit(JDSK) is
available from Sun Microsystems in order to develop
and deploy Java applications on desktop and servers
Installation : http://www.java.sun.com/j2se
After installation, important task is setting up of
environment variables
Steps: Control panel Click System Click Advanced
System Settings-Click Environment Variables
Set the path variable by mentioning the directory
C:\jdk1.06_4(your jdk directory)\bin.Click OK to save
settings.
Finally, go to cmd prompt and type javac

Tomcat Webserver

Tomcat installation : http://tomcat.apache.org


In configuration window, under Configuration Options setup, we can set the
connector port.
By default ,the port is 8080
We can also set the username and password for administrator login
After installation, we need to configure with environment variables
- Go to control panel-System Advanced tab
- Set the environmental variable i.e., Variable name : JAVA_HOME
- Set the environmental variable i.e., Variable value : your_jdk_directory
(
C: \jdk1.6.0_04 )
Again , Set the environmental variable i.e., Variable name : CATALINA_HOME
Set the environmental variable i.e., Variable value : your_tomcat_bin
directory
C:\Tomcat5.5\apache-tomcat-5.5.27\bin)
Now,you can start tomcat server by clicking on startup.bat batch file
in( C:\Tomcat5.5\apache-tomcat-5.5.27\bin)

You might also like