Download History of web servers

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
UNIT-I
INTRODUCTION TO WEB TECHNOLOGIES
Web Technolgies:
Web technologies related to the interface between web servers and their clients.
This information includes markup languages, programming interfaces and languages,
and standards for document identification and display.
What is Server?
1. A person or thing that provides a service or commodity, in particular.
2. A computer or computer program that manages access to a centralized resource
or service in a network.
In the context of client-server architecture, a server is a computer program
running to serve the requests of other programs, the "clients". Thus, the "server" performs
some computational task on behalf of "clients". The clients either run on the same
computer or connect through the network.
In most common use, server is a physical computer (a hardware system) dedicated
to running one or more such services (as a host), to serve the needs of users of the other
computers on the network. Depending on the computing service that it offers it could be a
database server, file server, mail server, print server, web server, or other.
Servers often provide essential services across a network, either to private users
inside a large organization or to public users via the Internet. For example, when you
enter a query in a search engine, the query is sent from your computer over the internet to
the servers that store all the relevant web pages. The results are sent back by the server to
your computer.
The term server is used quite broadly in information technology. Despite the
many server-branded products available (such as server versions of hardware, software or
operating systems), in theory any computerized process that shares a resource to one or
more client processes is a server. To illustrate this, take the common example of file
sharing. While the existence of files on a machine does not classify it as a server, the
mechanism which shares these files to clients by the operating system is the server.
Similarly, consider a web server application (such as the multiplatform "Apache
HTTP Server"). This web server software can be run on any capable computer. For
example, while a laptop or personal computer is not typically known as a server, they can
in these situations fulfill the role of one, and hence be labeled as one. It is in this case that
the machine's purpose as a web server classifies it in general as a server.
In the hardware sense, the word server typically designates computer models
intended for hosting software applications under the heavy demand of a network
environment. In this client–server configuration one or more machines, either a computer
or a computer appliance, share information with each other with one acting as a host for
the other.
BITS | By : K. Ravi Kumar(III-IT) 1
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
While nearly any personal computer is capable of acting as a network server, a
dedicated server will contain features making it more suitable for production
environments. These features may include a faster CPU, increased high-performance
RAM, and typically more than one large hard drive. More obvious distinctions include
marked redundancy in power supplies, network connections, and even the servers
themselves.
Types of servers
In a general network environment the following types of servers may be found.














Application server, a server dedicated to running certain software applications
Catalog server, a central search point for information across a distributed network
Communications server, carrier-grade computing platform for communications
networks
Database server, provides database services to other computer programs or
computers
Fax server, provides fax services for clients
File server, provides file services
Game server, a server that video game clients connect to in order to play online
together
Home server, a server for the home
Name server or DNS server
Print server, provides printer services
Proxy server, acts as an intermediary for requests from clients seeking resources
from other servers
Sound server, provides multimedia broadcasting, streaming.
Standalone server, an emulator for client–server (web-based) programs
Web server, a server that HTTP clients connect to in order to send commands and
receive responses along with data contents
Almost the entire structure of the Internet is based upon a client–server model. Highlevel root name servers, DNS servers, and routers direct the traffic on the internet. There
are millions of servers connected to the Internet, running continuously throughout the
world.
What is Web Server?
Web server can refer to either the hardware (the computer) or the software (the
computer application) that helps to deliver content that can be accessed through the
Internet.
The most common use of web servers is to host web sites but there are other uses
such as data storage or running enterprise applications.
BITS | By : K. Ravi Kumar(III-IT) 2
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Overview
The primary function of a web server is to deliver web pages on the request to
clients. This means delivery of HTML documents and any additional content that may be
included by a document, such as images, style sheets and scripts.
A client, commonly a web browser or web crawler, initiates communication by
making a request for a specific resource using HTTP and the server responds with the
content of that resource or an error message if unable to do so. The resource is typically a
real file on the server's secondary memory, but this is not necessarily the case and
depends on how the web server is implemented.
While the primary function is to serve content, a full implementation of HTTP
also includes ways of receiving content from clients. This feature is used for submitting
web forms, including uploading of files.
Many generic web servers also support server-side scripting, e.g., Active Server
Pages (ASP) and PHP. This means that the behavior of the web server can be scripted in
separate files, while the actual server software remains unchanged. Usually, this function
is used to create HTML documents "on-the-fly" as opposed to returning fixed documents.
This is referred to as dynamic and static content respectively. The former is primarily
used for retrieving and/or modifying information from databases. The latter is, however,
typically much faster and more easily cached.
Web servers are not always used for serving the World Wide Web. They can also
be found embedded in devices such as printers, routers, webcams and serving only a local
network. The web server may then be used as a part of a system for monitoring and/or
administrating the device in question. This usually means that no additional software has
to be installed on the client computer; since only a web browser is required (which now is
included with most operating systems).
History of web servers
In 1989 Tim Berners-Lee proposed a new project with the goal of easing the
exchange of information between scientists by using a hypertext system to his employer
CERN. The project resulted in Berners-Lee writing two programs in 1990:


A browser called WorldWideWeb
The world's first web server, later known as CERN httpd, which ran on
NEXTSTEP
Between 1991 and 1994, the simplicity and effectiveness of early technologies used
to surf and exchange data through the World Wide Web helped to port them to many
different operating systems and spread their use among socially diverse groups of people,
first in scientific organizations, then in universities and finally in industry.
BITS | By : K. Ravi Kumar(III-IT) 3
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
In 1994 Tim Berners-Lee decided to constitute the World Wide Web Consortium
(W3C) to regulate the further development of the many technologies involved (HTTP,
HTML, etc.) through a standardization process.
Common features




Virtual hosting to serve many Web sites using one IP address
Large file support to be able to serve files whose size is greater than 2 GB on 32
bit OS
Bandwidth throttling to limit the speed of responses in order to not saturate the
network and to be able to serve more clients
Server-side scripting to generate dynamic Web pages, still keeping web server
and website implementations separate from each other
History of Apache: “In February of 1995, the most popular server software on the web was the public
domain HTTP deamen developed by ‘Rob Mc Cod’ at the NCSA University of llionols
and urbana-champaign. However development of that HTTP had started after Rob left
NCSA in mid 1994 and many webmasters had developed their own intensions and bug
foxes that were In need of a common distribution by the end of the February, eight care
counter bufores formed the foundation of the arigrial Apache Group”
Apache HTTP Server
The Apache HTTP Server commonly referred to as Apache (/əˈpætʃiː/), is web
server software notable for playing a key role in the initial growth of the World Wide
Web. In 2009 it became the first web server software to surpass the 100 million website
milestone. Apache was the first viable alternative to the Netscape Communications
Corporation web server (currently named Oracle iPlanet Web Server), and since has
evolved to rival other web servers in terms of functionality and performance. Typically
Apache is run on a Unix-like operating system.
Apache is developed and maintained by an open community of developers under
the auspices of the Apache Software Foundation. The application is available for a wide
variety of operating systems, including Unix, GNU, FreeBSD, Linux, Solaris, Novell
NetWare, AmigaOS, Mac OS X, Microsoft Windows, OS/2, TPF, and eComStation.
Released under the Apache License, Apache is open-source software.
Apache was originally based on NCSA HTTPd code. The NCSA code is since
removed from Apache, due to a rewrite.
Since April 1996 Apache has been the most popular HTTP server software in use.
As of May 2011 Apache was estimated to serve 63% of all websites and 66% of the
million busiest.
BITS | By : K. Ravi Kumar(III-IT) 4
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Stronghold was a fork of the Apache HTTP Server, which included the Secure
Socket Layer software to enable https. It was created by C2Net, which was eventually
purchased by Red Hat. Stronghold's last support date was 2005-12-31.
Name
According to the FAQ in the Apache project website, the name Apache was
chosen out of respect to the Native American tribe Apache (Inde) and its superior skills in
warfare and strategy. In addition, the website claims that the name's story resulting from
the server being A Patchy server (since it was a conjunction of software patches) is
popular, but incorrect.
Features
Apache supports a variety of features, many implemented as compiled modules
which extend the core functionality. These can range from server-side programming
language support to authentication schemes. Some common language interfaces support
Perl, Python, Tcl, and PHP. Popular authentication modules include mod_access,
mod_auth, mod_digest, and mod_auth_digest, the successor to mod_digest. A sample of
other features include Secure Sockets Layer and Transport Layer Security support
(mod_ssl), a proxy module (mod_proxy), a URL rewriter (also known as a rewrite
engine, implemented under mod_rewrite), custom log files (mod_log_config), and
filtering support (mod_include and mod_ext_filter).
Popular compression methods on Apache include the external extension module,
mod_gzip, implemented to help with reduction of the size (weight) of web pages served
over HTTP. ModSecurity is an open source intrusion detection and prevention engine for
web applications. Apache logs can be analyzed through a web browser using free scripts
such as AWStats/W3Perl or Visitors.
Virtual hosting allows one Apache installation to serve many different actual
websites. For example, one machine with one Apache installation could simultaneously
serve www.example.com, www.example.org, test47.test-server.example.edu, etc.
Apache features configurable error messages, DBMS-based authentication
databases, and content negotiation. It is also supported by several graphical user
interfaces (GUIs).
It supports password authentication and digital certificate authentication. Apache
has a built in search engine and an HTML authorizing tool and supports FTP.
Performance
Although the main design goal of Apache is not to be the "fastest" web server,
Apache does have performance comparable to other "high-performance" web servers.
Instead of implementing a single architecture, Apache provides a variety of
Multiprocessing Modules (MPMs) which allow Apache to run in a process-based, hybrid
(process and thread) or event-hybrid mode, to better match the demands of each
BITS | By : K. Ravi Kumar(III-IT) 5
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
particular infrastructure. This implies that the choice of correct MPM and the correct
configuration is important. Where compromises in performance need to be made, the
design of Apache is to reduce latency and increase throughput, relative to simply
handling more requests, thus ensuring consistent and reliable processing of requests
within reasonable time-frames.
The Apache version considered by the Apache Foundation as providing highperformance is the multi-threaded version which mixes the use of several processes and
several threads per process.
While this architecture works faster than the previous multi-process based
topology (because threads have a lower overhead than processes), it does not match the
performances of the event-based architecture provided by other servers, especially when
they process events with several worker threads.
This difference can be easily explained by the overhead that one thread per
connection brings (as opposed to a couple of worker threads per CPU, each processing
many connection events). Each thread needs to maintain its own stack, environment, and
switching from one thread to another is also an expensive task for CPUs.
Licensing
With the release of Apache 2.0, the Apache Foundation changed its license. Some
Apache users did not like the change and continued the use of pre-2.0 Apache versions
(typically 1.3.x). The OpenBSD project went to the extent of effectively forking Apache
1.3.x for its purposes.
Internet Information Services
Internet Information Services (IIS) – formerly called Internet Information
Server – is a web server application and set of feature extension modules created by
Microsoft for use with Microsoft Windows. It is the most used web server after Apache
HTTP Server. IIS 7.5 supports HTTP, HTTPS, FTP, FTPS, SMTP and NNTP. It is an
integral part of Windows Server family of products, as well as certain editions of
Windows XP, Windows Vista and Windows 7. IIS is not turned on by default when
Windows is installed.
History
The first Microsoft web server was a research project at European Microsoft
Windows NT Academic Centre (EMWAC), part of the University of Edinburgh in
Scotland, and was distributed as freeware. However, since the EMWAC server was
unable to scale sufficiently to handle the volume of traffic going to microsoft.com,
Microsoft was forced to develop its own web server, IIS.
Almost every version of IIS was released either alongside or with a version of
Microsoft Windows operating system. IIS 1.0 was initially released as a free add-on, a set
BITS | By : K. Ravi Kumar(III-IT) 6
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
of web-based services for Windows NT 3.51. However, IIS 2.0 was included with
Windows NT 4.0. IIS 3.0, which was included with Service Pack 3 of Windows NT 4,
introduced the Active Server Pages dynamic scripting environment.[3] IIS 4.0 was
released as part of an "Option Pack" for Windows NT 4.0 and dropped support for the
Gopher protocol. IIS 5.0 shipped with Windows 2000 and introduced additional
authentication methods; management enhancements including a new MMC based
administration application, support for the WebDAV protocol, and enhancements to ASP.
IIS 5.1 was shipped with Windows XP Professional, and was nearly identical to IIS 5.0
on Windows 2000 except for several limitations Microsoft introduced. IIS 5.1 supported
only 10 simultaneous connections and supported only a single web site.IIS 6.0, included
with Windows Server 2003 and Windows XP Professional x64 Edition, added support for
IPv6 and included a new worker process model that increased security as well as
reliability.
IIS 7.0 was a complete redesign and rewrite of IIS, and was shipped with
Windows Vista and Windows Server 2008. IIS 7.0 included a new modular design that
allowed for a reduced attack surface and increased performance. IIS 7.0 also introduced a
hierarchical configuration system allowing for simpler site deploys, a new Windows
Forms based management application, new command line management options and
increased support for the .NET Framework.IIS 7.0 on Vista does not limit the number of
allowed connections as IIS on XP did, but limits concurrent requests to 10 (Windows
Vista Ultimate, Business, and Enterprise Editions) or 3 (Vista Home Premium).
Additional requests are queued, which hampers performance, but they are not rejected as
with XP.
The current shipping version of IIS is IIS 7.5, included in Windows 7 and
Windows Server 2008 R2. IIS 7.5 improved WebDAV and FTP modules as well as
command line administration in PowerShell. It also introduced Best Practices Analyzer
tool and process isolation for application pools.
Versions
5.1, Windows XP Professional and Windows XP Media Center Edition (requires
retail CD)
6.0, Windows Server 2003 and Windows XP Professional x64 Edition
7.0, Windows Server 2008 and Windows Vista (Home Premium, Business,
Enterprise and Ultimate editions)
7.5, Windows Server 2008 R2 and Windows 7 (Home Premium, Professional,
Enterprise and Ultimate editions)
Features
The architecture of IIS 7 is modular. Modules, also called extensions, can be added or
removed individually so that only modules required for specific functionality have to be
installed. IIS 7 includes native modules as part of the full installation. These modules are
individual features that the server uses to process requests and include the following:
BITS | By : K. Ravi Kumar(III-IT) 7
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES






HTTP modules – Used to perform tasks specific to HTTP in the requestprocessing pipeline, such as responding to information and inquiries sent in client
headers, returning HTTP errors, and redirecting requests.
Security modules – Used to perform tasks related to security in the requestprocessing pipeline, such as specifying authentication schemes, performing URL
authorization, and filtering requests.
Content modules – Used to perform tasks related to content in the requestprocessing pipeline, such as processing requests for static files, returning a default
page when a client does not specify a resource in a request, and listing the
contents of a directory.
Compression modules – Used to perform tasks related to compression in the
request-processing pipeline, such as compressing responses, applying Gzip
compression transfer coding to responses, and performing pre-compression of
static content.
Caching modules – Used to perform tasks related to caching in the requestprocessing pipeline, such as storing processed information in memory on the
server and using cached content in subsequent requests for the same resource.
Logging and Diagnostics modules – Used to perform tasks related to logging and
diagnostics in the request-processing pipeline, such as passing information and
processing status to HTTP.sys for logging, reporting events, and tracking requests
currently executing in worker processes.
Comparison of Apache and IIS
IIS pros and cons
Pros: 1) Easy to get started.
2) Little or no tuning is required.
3) ASP is easy to use
4) Integrated ODBC (open database community) is support.
5) GUI and command line administrator interfaces.
Cons: 1) Crash may require complete system rebuild and restart from backups.
2) Most additional functionality requires software purchase.
3) A poorly written looping script can kill the web server.
Apache pros and cons
Pros: 1)
2)
3)
4)
Open source project under active development.
Flexible and powerful.
ODBC interface is available without cost.
Extensible (can link new modules in to the core server).
BITS | By : K. Ravi Kumar(III-IT) 8
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Cons: 1) Initial configuration and tuning may be required.
2) Language learning for effective use.
Differences between Apache and IIS(information internet services)
S.no
1
2
3
4
5
6
7
Apache
It is a cross platform
MPM’s is implemented
Free software.
The user has the capability to alter
the module according to the user
requirement.
The module used is mod_rewrite.
New version of apache can be
enhanced in any operating system
(os).
Very high security.
S.no
1
2
3
4
IIS
Only in windows os.
No multithreading.
Not free software.
IIS doesn’t allow users to modify or
create new module.
5
IIS can’t be enhanced in higher
version os of windows
6
Vulnerable (Exposed to
attacked or harmed).
DOT NET is integrated.
Integrating
DOT NET is not 7
possible
Bug can be fixed by adding free 8
patches.
8
being
To fix bugs an administrator is need
and also more expense.
XAMPP
XAMPP is a free and open source cross-platform web server solution stack
package, consisting mainly of the Apache HTTP Server, MySQL database, and
interpreters for scripts written in the PHP and Perl programming languages.
Etymology
XAMPP's name is an acronym for:





X (to be read as "cross", meaning cross-platform)
Apache HTTP Server
MySQL
PHP
Perl
The program is released under the terms of the GNU General Public License and acts
as a free web server capable of serving dynamic pages. XAMPP is available for
Microsoft Windows, Linux, Solaris, and Mac OS X, and is mainly used for web
development projects. This software is useful while you are creating dynamic WebPages
using programming languages like PHP, JSP, Servlets.
BITS | By : K. Ravi Kumar(III-IT) 9
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Requirements and features
XAMPP requires only one zip, tar, 7z, or exe file to be downloaded and run, and
little or no configuration of the various components that make up the web server is
required. XAMPP is regularly updated to incorporate the latest releases of
Apache/MySQL/PHP and Perl. It also comes with a number of other modules including
OpenSSL and phpMyAdmin.
Installing XAMPP takes less time than installing each of its components
separately. Self-contained, multiple instances of XAMPP can exist on a single computer,
and any given instance can be copied from one computer to another.
It is offered in both a full, standard version and a smaller version.
Use
Officially, XAMPP's designers intended it for use only as a development tool, to
allow website designers and programmers to test their work on their own computers
without any access to the Internet. To make this as easy as possible, many important
security features are disabled by default. In practice, however, XAMPP is sometimes
used to actually serve web pages on the World Wide Web. A special tool is provided to
password-protect the most important parts of the package.
XAMPP also provides support for creating and manipulating databases in MySQL
and SQLite among others.
Once XAMPP is installed you can treat your localhost like a remote host by
connecting using an FTP client. Using a program like FileZilla has many advantages
when installing a content management system (CMS) like Joomla. You can also connect
to localhost via FTP with your HTML editor.
The default FTP user "newuser", the default FTP password is "wampp".
The default MySQL user is "root" while there is no default MySQL password.
Screenshots

Xampp Control panel

Xampp Status
After starting of Apache (and MySQL), go to the address http://localhost/ or
http://127.0.0.1/ in your browser and examine all of the XAMPP examples and tools.

Xampp Security
With the security console you can set a password for the MySQL user "root" and
phpMyAdmin.
BITS | By : K. Ravi Kumar(III-IT) 10
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
WAMP
WAMPs are packages of independently-created programs installed on computers
that use a Microsoft Windows operating system.
WAMP is an acronym formed from the initials of the operating system Microsoft
Windows and the principal components of the package: Apache, MySQL and one of
PHP, Perl or Python. Apache is a web server. MySQL is an open-source database. PHP is
a scripting language that can manipulate information held in a database and generate web
pages dynamically each time content is requested by a browser. Other programs may also
be included in a package, such as phpMyAdmin which provides a graphical user interface
for the MySQL database manager, or the alternative scripting languages Python or Perl.
Equivalent packages are MAMP (for the Apple Mac) and LAMP (for the Linux operating
system).
Using Tomcat For Servlet Development:
To create servlets, you will need to download a servlet development environment.
The one currently recommended by Sun is Tomcat 4.0, which supports the latest servlet
specification, which is 2.3. (The complete servlet specification is available for download
through java.sun.com.) Tomcat replaces the old JSDK (Java Servlet Development Kit)
that was previously provided by Sun. Tomcat is an open-source product maintained
by the Jakarta Project of the Apache Software Foundation. It contains the class libraries,
documentation, and run-time support that you will need to create and test servlets.
You can download Tomcat through the Sun Microsystems Web site at
java.sun.com.The current version is 4.0. Follow the instructions to install this toolkit on
your machine. The examples in this chapter assume a Windows environment. The default
location for Tomcat 4.0 is
C:\Program Files\Apache Tomcat 4.0\
This is the location assumed by the examples in this book. If you load Tomcat in a
different location, you will need to make appropriate changes to the examples. You may
need to set the environmental variable JAVA_HOME to the top-level directory in which
the Java Software Development Kit is installed. For Java 2, version 1.4, the default
directory is C:\j2sdk1.4.0, but you will need to confirm this for your environment.
To start Tomcat, select Start Tomcat in the Start | Programs menu, or run startup.bat
from the
C:\Program Files\Apache Tomcat 4.0\bin\
directory. When you are done testing servlets, you can stop Tomcat by selecting Stop
Tomcat in the Start | Programs menu, or run shutdown.bat.
The directory
C:\Program Files\Apache Tomcat 4.0\common\lib\
contains servlet.jar. This JAR file contains the classes and interfaces that are needed
to build servlets. To make this file accessible, update your CLASSPATH environment
variable so that it includes
C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar.
BITS | By : K. Ravi Kumar(III-IT) 11
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Alternatively, you can specify this class file when you compile the servlets. For
example, the following command compiles the first servlet example:
javac HelloServlet.java -classpath "C:\Program Files\Apache Tomcat
4.0\common\lib\servlet.jar"
Once you have compiled a servlet, you must copy the class file into the directory
that Tomcat uses for example servlet class files. For the purposes of this chapter, you
must put the servlet files into the following directory:
C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes
A Simple Servlet:
To become familiar with the key servlet concepts, we will begin by building and
testing a simple servlet. The basic steps are the following:
1. Create and compile the servlet source code.
2. Start Tomcat.
3. Start a Web browser and request the servlet.
Let us examine each of these steps in detail.
Create and Compile the Servlet Source Code
To begin, create a file named HelloServlet.java that contains the following
program:
import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}
HANDLING HTTP REQUESTS AND RESPONSES:
Servlets can be used for handling both the GET Requests and the POST Requests.
However in this post, let’s write the code for handling the GET Request. The HttpServlet
class is used for handling HTTP GET Requests as it has some specialized methods that
can efficiently handle the HTTP requests. These methods are;







doGet()
doPost()
doPut()
doDelete()
doOptions()
doTrace()
doHead()
BITS | By : K. Ravi Kumar(III-IT) 12
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
HANDLING GET REQUESTS:
An individual developing servlets for handling HTTP Requests needs to override one
of these methods in order to process the request and generate a response. The servlet is
invoked
dynamically
when
an
end-user
submits
a
form.
Let’s look at a sample HTML FORM
<form name="F1" action=/servlet/ColServlet>
Select the color:
<select name = "col" size = "3">
<option value = "blue">Blue</option>
<option value = "orange">Orange</option>
</select>
<input type = "submit" value = "Submit">
</form>
Here’s the code for ColServlet.java that overrides the doGet() method to retrieve
data from the HTTP Request and it then generates a response as well.
// import the java packages that are needed for the servlet to work
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// defining a class
public class ColServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
ServletException, IOException
// request is an object of type HttpServletRequest and it's used to obtain information
// response is an object of type HttpServletResponse and it's used to generate a response
// throws is used to specify the exceptions than a method can throw
{
String colname = request.getParameter("col");
// getParameter() method is used to retrieve the selection made by the user
response.setContentType("text/html");
PrintWriter info = response.getWriter ();
info.println("The color is: ");
info.println(col);
info.close();
}
}
BITS | By : K. Ravi Kumar(III-IT) 13
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Compile the servlet and perform these steps to test this example:
1.Start Tomcat, if it not already running.
2.Display the Web page in a browser.
3.Select a color.
4.Submit the web page.
After completing these steps, the browser will display the response that is dynamically
generated by the servlet.
One Other Point: Parameters for an HTTP GET request are included as part of the
URL,that is sent to the web server. Assume that the user selects the red option and submit
the form. The URL sent from the browser to the server is
http://localhost:8080/examples/sevlet/ColServlet?color=Red
The characters to the right of the question are known as the Query String.
HANDLING POST REQUESTS:
Servlets can be used for handling both the POST Requests and the POST Requests.
However, let’s write the code for handling the POST Request. The HttpServlet class is
used for handling HTTP POST Requests as it has some specialized methods that can
efficiently handle the HTTP requests. These methods are;







doGet()
doPost()
doPut()
doDelete()
doOptions()
doTrace()
doHead()
An individual developing servlets for handling HTTP Requests needs to override one
of these methods in order to process the request and generate a response. The servlet is
invoked
dynamically
when
an
end-user
submits
a
form.
Let’s look at a sample HTML FORM
<form name="F1" method=”post” action=/servlet/ColServlet>
Select the color:
<select name = "col" size = "3">
<option value = "blue">Blue</option>
<option value = "orange">Orange</option>
</select>
<input type = "submit" value = "Submit">
</form>
BITS | By : K. Ravi Kumar(III-IT) 14
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Here’s the code for ColServlet.java that overrides the doPost() method to retrieve
data from the HTTP Request and it then generates a response as well.
// import the java packages that are needed for the servlet to work
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// defining a class
public class ColServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws
ServletException, IOException
// request is an object of type HttpServletRequest and it's used to obtain information
// response is an object of type HttpServletResponse and it's used to generate a response
// throws is used to specify the exceptions than a method can throw
{
String colname = request.getParameter("col");
// getParameter() method is used to retrieve the selection made by the user
response.setContentType("text/html");
PrintWriter info = response.getWriter ();
info.println("The color is: ");
info.println(col);
info.close();
}
}
In order to make this code work, compile the servlet and open the HTML file and
hit the “submit” button after selecting a color. Once you press the submit button, the
browser will display a response that is generate dynamically by invoking the servlet.
Well, this was a very simple servlet and it’s always good to start with basic stuff.
However, there’s no end to what you can do with Java Servlets as you can make complex
servlets to do several complex tasks.
Note: Parameters for an HTTP POST request are not included as part of the URL that is
sent to the web server. In this example, the URL sent from the browser to the server is:
http://localhost:8080/examples/servlet/ColServlet the parameter names and values are
sent in the body of the HTTP request.
BITS | By : K. Ravi Kumar(III-IT) 15
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Downloading the Apache web server
The Apache web server is available in three different series: 1.3, 2.0, and 2.2.
Since 2.0 is recommended over 1.3 for running on Windows XP, and software like PHP
as far as I know don't support 2.2 yet, I decided to install the latest 2.0.x version which is
2.0.59 at this time of writing.
Go to the Apache HTTP server download page and select the series you want to
use (either 1.3 or 2.0) and download the Win32 binary. In my case I downloaded
apache_2.0.59-win32-x86-no_ssl.msi.
Downloading the Apache Win32 MSI installer.
After you have downloaded the MSI file compare the MD5 signature with the
value published on the Apache website. Note: I am working on an explanation on how to
do this, for now read the instructions on the Apache HTTP server download page.
Installing the Apache web server
If you set up your day-to-day account properly on Windows XP you are working
as a limited user. For installation of the Apache HTTP server you need to have
Administrator rights. So go to the Windows XP Login screen by pressing the Windows
key (between the left Ctrl and left Alt on most keyboards) and the L key together.
When started, the Apache HTTP server installation wizard displays a welcome
message. Click on the Next button to continue. Next, the Apache license is shown. Read
it carefully and if you accept the license, select the "I accept the terms in the license
agreement" option and press the Next button.
Next a "Read This First" document is displayed. Read it carefully before pressing
the Next button.
BITS | By : K. Ravi Kumar(III-IT) 16
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Apache HTTP server information
Next, you can enter your server information. Since I don't need other computers
on the local network to be able to contact the web server I used localhost. If you have a
local network, and want other computers to be able to contact the computer, make sure
you use the right settings. If you don't know which option you want, use localhost for
now, since you can always change the configuration settings later on in the configuration
file of the Apache web server.
I recommend to run the Apache HTTP server as a service. This way it is always
running and you don't need to start it manually. If you consider manually start and stop
because of security issues, then reconsider and use a firewall, preferable one running on
an external device like a router.
The next step allows you to select the install type of the Apache web server. The
default (Typical program features) is probably right for your situation, so press Next.
Next, you can select the destination folder of the installation. Unless you prefer to
use a different folder for some or all of the software you install, I recommend to use the
default setting: C:\Program Files\Apache Group\
Finally, after clicking on the Next button you can start the actual installation by pressing
the Install button. A few windows pop up and go automatically, and then a Windows
Security Alert window appears asking if you want to keep blocking this (Apache HTTP
server) program.
BITS | By : K. Ravi Kumar(III-IT) 17
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Windows Security Alert for the Apache HTTP server.
Since I don't want to make the web server available on the network I selected the
Keep Blocking option. Note that you can always change this into Unblock later in case
you decide to make the Apache HTTP server available on your network. After selecting a
button in the Windows Security Alter dialogue window the window closes itself and the
Apache HTTP Server 2.0 Installation Wizard reports that the Apache HTTP server has
been installed successfully. Click the Finished button to close the HTTP server
installation wizard.
Testing the Apache HTTP server installation
In order to test your Apache web server installation, open a browser and enter
http://localhost/ into the address bar (unless you used a different value then localhost in
the Apache server information step). The Test Page for Apache installation should be
displayed into your browser.
Part of the Apache HTTP server test page in Mozilla Firefox
BITS | By : K. Ravi Kumar(III-IT) 18
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
If you don't get the test page it might be that the Apache web server was not able
to start for some reason, check the error.log file in the logs folder of the web server (see
the next section).
Understanding the Apache server folder structure
It is important to understand some part of the Apache HTTP server folder
structure, or where is what located. I won't describe each and every item, but just mention
the important ones:
Apache folder structure
The bin folder
The bin folder contains amongst other files the server executable: Apache.exe and
a program to control the Apache HTTP server when ran as service: ApacheMonitor.exe.
Also contained in this folder are htpasswd.exe and htdigest.exe for making parts of your
site(s) restricted.
The cgi-bin folder
The cgi-bin folder has one CGI program written in Perl, printenv.pl, which you
can use to test if your Perl installation is working in combination with the Apache HTTP
server. If you get a "500 Internal Server Error" when you enter http://localhost/cgibin/printenv.pl in the address bar of your browser, you either have Perl not installed, or
the configuration of the web server is not right. You might want to check the error.log file
in the logs folder in the latter case.
BITS | By : K. Ravi Kumar(III-IT) 19
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
The conf folder
This folder holds the configuration files used by the Apache web server. Of each file
used by the server there is a copy which has .default in its name, e.g. httpd.default.conf.
The access.conf and srm.conf files are empty (except for comments) by default, and I
recommend to not use those files for configuring the server. The httpd.conf file has
already been updated by the installation process. I list some of those modified settings
below, including a short description and the line number (which might differ with your
version).



Listen 80 - The port the Apache server is using. If you have already a web server
running, for example as part of Microsoft Internet Information Services (IIS), you
might want to change the number to something different (line 120).
ServerAdmin admin@localhost - The email address of the server administrator,
which is used on, for example, error pages generated by the server (line 198).
ServerName localhost:80 - The hostname and port the server uses (line 212).
Some of the other settings are omitted since they will be overridden by the name-based
virtual hosting set up discussed below.
htdocs
This folder contains the default HTML page you see when you visit
http://localhost/ with your web browser. Don't start adding your HTML documents and
related files to this folder, but read on.
manual
This folder contains the Apache HTTP server documentation, available as
http://localhost/manual/. Note that this folder shows up under the document root thanks to
the AliasMatch directive in the httpd.conf server configuration file (line 491).
logs
This folder contains (amongst others) the access.log and error.log files. If
anything goes wrong, for example the notorious 500 Internal Server Error, make sure that
you check the error.log file. With virtual hosting you can give each site its own log file
(discussed below), so be sure to check the right file(s).
Stopping and starting Apache
After changes have been made to the httpd.conf file and/or the virtual-hosts file,
Apache has to be restarted. If you are logged in with Administrator rights the easiest way
to do this is by using the Apache monitor which is started when you log in and available
via the system tray. Click the right mouse (context menu) button on the red feather icon
in the system tray and select the Open Apache Monitor menu entry. You can restart the
Apache HTTP server with a single mouse click on the Restart button.
BITS | By : K. Ravi Kumar(III-IT) 20
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
The Apache service monitor.
Note that during installation of the Apache web server a short cut to the Apache
service monitor is created in the Startup folder of "All Users" (i.e. C:\Documents and
Settings\All Users\Start Menu\Programs\Startup) which is quite useless. Users with
limited access rights are not able to control the Apache service but will get the Apache
monitor running in their system tray anyway. You might want to move the short cut to
the Startup folder of a user with Administrator rights.
Another way to restart Apache is by entering in a command prompt window NET
STOP APACHE2 followed by enter, followed by NET START APACHE2 to stop and
start the Apache service:
NET STOP APACHE2
The Apache2 service is stopping.
The Apache2 service was stopped successfully.
NET START APACHE2
The Apache2 service is starting.
The Apache2 service was started successfully
Note that this only works if the command prompt has Administrator rights. As a
limited user open the "Accessories" of the "All Programs" menu in the Start menu. Place
the mouse pointer on top of the Command Prompt entry, press the right (context menu)
mouse button, and select the "Run As..." option. In the "Run as" dialog window switch to
"The following user" and select a user with Administrator rights from the drop down
menu and enter the password for the selected user. In a similar manner a user with limited
rights can run ApacheMonitor.exe located in C:\Program Files\Apache
BITS | By : K. Ravi Kumar(III-IT) 21
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Group\Apache2\bin. However, most of the time switching to an account with
Administrator rights is more convenient.
Testing Apache:
After starting Apache (either in a console window or as a service) it will be
listening on port 80 (unless you changed the Listen directive in the configuration files or
installed Apache only for the current user). To connect to the server and access the
default page, launch a browser and enter this URL:
http://localhost/
Apache should respond with a welcome page and a link to the Apache manual. If
nothing happens or you get an error, look in the error.log file in the logs subdirectory. If
your host is not connected to the net, or if you have serious problems with your DNS
(Domain Name Service) configuration, you may have to use this URL:
http://127.0.0.1/
If you happen to be running Apache on an alternate port, you need to explicitly put that in
the URL:
http://127.0.0.1:8080/
Once your basic installation is working, you should configure it properly by
editing the files in the conf subdirectory. Again, if you change the configuration of the
Windows NT service for Apache, first attempt to start it from the command line to make
sure that the service starts with no errors. Because Apache cannot share the same port
with another TCP/IP application, you may need to stop, uninstall or reconfigure certain
other services before running Apache. These conflicting services include other WWW
servers and some firewall implementations.
Installing IIS on Windows XP Pro:
If you are running Windows XP Professional on your computer you can install
Microsoft's web server, Internet Information Server 5.1 (IIS) for free from the Windows
XP Pro installation CD and configure it to run on your system by following the
instructions
below:
1. Place the Windows XP Professional CD-Rom into your CD-Rom Drive.
2. Open 'Add/Remove Windows Components' found in 'Add/Remove Programs' in the
'Control
Panel'.
3. Place a tick in the check box for 'Internet Information Services (IIS)' leaving all the
default
installation
settings
intact.
4. Once IIS is installed on your machine you can view your home page in a web browser
BITS | By : K. Ravi Kumar(III-IT) 22
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
by typing 'http://localhost' (you can substitute 'localhost' for the name of your computer)
into the address bar of your web browser. If you have not placed your website into the
default directory you should now be looking at the IIS documentation.
5. If you are not sure of the name of your computer right-click on the 'My Computer' icon
on your desktop, select 'Properties' from the shortcut menu, and click on the 'Computer
Name'
tab.
6. Your default web directory to place your website in is 'C:\Inetpub\wwwroot', but if you
don't want to over write the IIS documentation found in this directory you can set up your
own virtual directory through the 'Internet Information Services' console.
7. The 'Internet Information Services' console can be found in the 'Administration Tools'
in the 'Control Panel' under 'Performance and Maintenance', if you do not have the
control panel in Classic View.
8. Double-click on the 'Internet Information Services' icon.
9. Once the 'Internet Information Services' console is open you will see any IIS web
services you have running on your machine including the SMTP server and FTP server, if
you
chose
to
install
them
with
IIS.
10. To add a new virtual directory right click on 'Default Website' and select 'New',
followed by 'Virtual Directory', from the drop down list.
BITS | By : K. Ravi Kumar(III-IT) 23
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
11. Next you will see the 'Virtual Directory Creation Wizard' from the first screen click
the
'next'
button.
12. You will then be asked to type in an 'Alias' by which you will access the virtual
directory from your web browser (this is the name you will type into your web browser
after 'localhost' to view any web pages you place in the directory).
13. Next you will see a 'Browse...' button, click on this to select the directory your
website pages are in on your computer, after which click on the 'next' button to continue.
14. On the final part of the wizard you will see a series of boxes, if you are not worried
about security then select them all, if you are and want to run ASP scripts then check the
first
two,
followed
by
the
'next'
button.
15. Once the virtual directory is created you can view the web pages in the folder by
typing 'http://localhost/aliasName' (where 'aliasName' is, place the alias you called the
virtual directory) into the address bar of your web browser (you can substitute 'localhost'
for the name of your computer if you wish).
BITS | By : K. Ravi Kumar(III-IT) 24
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
INSTALLATION OF XAMPP:
XAMPP is a fully functional web server package. It is built to test web based
programs on a personal computer. It is not meant for online access via the web on a
production server. This page describes how to install the XAMPP web server package of
programs on the server which was created.
Overview:
Note: This page was updated showing an installation for XAMPP 1.7.1 but some older
screenshots were kept.
This is a guide for installing XAMPP on a computer using the Windows XP operating
system, but it is still usable for Vista.
An overview of the steps:




Download the latest version of XAMPP from Apachefriends.org
Install XAMPP
Start XAMPP, which will start Apache and MySQL
Confirm webserver is operating with your browser
Preparation:
Get XAMPP
Go to apachefriends.org and download XAMPP for Windows. This example assumes that
you have downloaded the “Installer” package. There are several XAMPP packages to
download. Installer is about 1/2 the size of the same package as a zip file.
Installing XAMPP
Run the installer, eventually you will be presented with an option about where to install
the package. We told it to install it in a new folder called C:\X_server which XAMPP
will create. You could use the browse button to point to a location.
Continue with the installation, this will take a while!
BITS | By : K. Ravi Kumar(III-IT) 25
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Installation info screen
Eventually you will be presented with the option to install Apache, MySQL, Filezilla and
Mercury as a service.

It’s probably best to choose “No” for now. You can always enable these as
services later.
Next you’ll be asked if you want to start the XAMPP Control Panel.

Click the “No” button.
Launch XAMPP
There are several ways to start your webserver.
Server directory start/stop files
BITS | By : K. Ravi Kumar(III-IT) 26
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
One way to start/stop: XAMPP control panel
1. On your Desktop, locate the shortcut XAMPP icon and double click to launch the
Control Panel.
o
When the XAMPP Control Panel has launched, click the “Start” buttons
for Apache and MySQL (see below).
2. In the folder you installed XAMPP, look for the XAMPP_start, or XAMPP_restart
icon.
o
When XAMPP start has finished, both Apache and MySQL have been
started.
3. In the folder you installed XAMPP, look for the Apache start and MySQL start icons
o

When Apache and MySQL start icons are used, two black windows
command window should remain open
If all is well you will see something like this.
If Apache fails to run i.e. the "Running" text with the green background keeps
disappearing) and you are using Skype or another program that uses port 80 e.g.
IIS - please review "Troubleshooting" at the end of these instructions.
Then you have to install the PHP curl library :
1. Open the php.ini file found in the php/php.ini folder
(older versions of XAMPP use moodle/apache/bin folder)
2. Find the line: ;extension=php_curl.dll
3. Remove the ; at the beginning of the line
4. Restart Apache if necessary
BITS | By : K. Ravi Kumar(III-IT) 27
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
Installation of WAMP Server on XP:
WAMP stands for Windows Apache MySQL PHP. WAMP Server is an open source
software, which is free to use under the GPL licence (General Public Licence). Wamp
is a combination of numbers of software that allows to develop dynamic website with
Apache Server, MySQL database and PHP script language.
It also provides the facility of PHPMYAdmin and SQLite manager to handle the
database more easily and effectively.
We are installing the WAMP 2.0i version, that includes the latest version of Apache
2.2.11, PHP 5.3.0 and MySQL 5.1.36.
Let's see installation of Wamp on XP step by step :
1.Download Wamp
You can download wamp from any website by clicking on download tab or link
2.Save File
3. Double Click on Installer WampServer 2.0i
4.Click Run to Install
BITS | By : K. Ravi Kumar(III-IT) 28
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
5.Click Next
6. Select Option I accept and then click on next.
BITS | By : K. Ravi Kumar(III-IT) 29
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
7. Choose the directory and click next.
8. Select Additional Icon
BITS | By : K. Ravi Kumar(III-IT) 30
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
You can select either one or both the icon and then click on next button.
.
10. Click Install
11. Installing Process
The installing process going on wait for while to install the wamp.
BITS | By : K. Ravi Kumar(III-IT) 31
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
12. Click Next
13. Click Finish
The moment you click on finish button, your Wamp Server installed on your computer.
BITS | By : K. Ravi Kumar(III-IT) 32
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
14. Take a look on Wamp Setting.
Look at your right hand side of your task bar, there was a small wamp icon in the shape
of semi-circle.
Just left click on the icon and look at all the setting are available here. You can also
change the setting according to your requirement.
15. Take a look on WampServer.
BITS | By : K. Ravi Kumar(III-IT) 33
UNIT-I : INTRODUCTION TO WEB TECHNOLOGIES
The WampServer shows all the configuration of all the software and also two
tools on the left hand side. The first one is phpinfo() from there you can get information
about the php and the second one is phpmyadmin, this is your database and you can
create database by clicking on the phpmyadmin.
Note: For More details visit site www.Wikipedia.org
***** THE END *****
BITS | By : K. Ravi Kumar(III-IT) 34