Servlet Tutorial for Beginner

In this Post, we will first understand the web request and response processing through server.

The web contains billions client and server which connected through the network. Web clients make requests to the web servers.
The web server receives the request, finds the resources, and returns the response to the client. When a server answers a request, it usually sends some type of content to the client.
The client uses a web browser to send a request to the server. 
The server often sends a response to the browser with a set of instructions written in HTML(HyperText Markup Language). 
All browsers know how to display an HTML page to the client. 

Web Server, Application Server, and Web Client: 
Web Server: Web Server is a software that can process the client's request and send the response back to the client. 

For example, Apache is one of the most widely used web server. Web Server runs on some physical machine and listens to client requests on a specific port. 

Application Server: 
Most of the application servers have Web Server as integral part of them, that means App Server can do whatever Web Server is capable of. Additionally App Server have components and features to support Application level services such as Connection Pooling, Object Pooling, Transaction Support, Messaging services etc. e.g. WebLogic.

Web Client: 
A web client is a software that helps in communicating with the server. Some of the most widely used web clients are Firefox, Google Chrome, Safari etc. 
When we request something from server (through URL), web client takes care of creating a request and sending it to server and then parsing the server response and present it to the user. 

 HTTP: 
• HTTP stands for hypertext tranfer protocol. 
• It is used to send files (text, graphics, images, sounds, video and other multimedia files) on the web. 
• It's a stateless, application-layer protocol for communicating between distributed systems. 
• The current version of the protocol is HTTP/1.1. 
• The default port number for HTTP is 80.

HTTP Methods and Descriptions :

Method Name

Method Description

OPTIONS

Request for communication options that are available on the request/response.

GET

Request to retrieve information from server using a given URL.

HEAD

Identical to GET except that it does not return a message body , only the headers and status line.

POST

Request for server to accept the entity enclosed in the body of HTTP method.

DELETE

Request for the Server to delete the resource.

CONNECT

Reserved to use with a proxy that can switch to being a tunnel.

PUT

This is same as POST, but POST is used to create, PUT can be used to create as well as update. It replaces all current representations of the target resource with the uploaded content.
















Web Application:
A web application is an application accessible from the web. A web application is composed of web components like Servlet, JSP, Filter etc. and other components such as HTML. 
The web components typically execute in Web Server and respond to HTTP request. 

Common Gateway Interface: 
CGI(Common Gateway Interface) which is used before the Servlet. It is used to create web application. 

Working of CGI:
• User clicks a link that has URL to a dynamic page instead of a static page.  
• The URL decides which CGI program to execute. 
• Web servers run the CGI program in seperate OS shell. The shell includes OS environment and the process to execute code of the CGI program. 
• The CGI response is sent back to the web server, which wraps the response in an HTTP response and send it back to the web browser. 


                                    Working of CGI(Common Gateway Interface)

Drawbacks of CGI: 
• High response time because CGI programs execute in their own OS shell. 
• CGI is not scalable. 
• CGI programs are not always secure or object-oriented. 
• It is Platform dependent. 


Recommended Topics:


Previous
Next Post »

ConversionConversion EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng