In this post we will learn about HTTP and how does it works and use of HTTP in servlet.HTTP(Hyper Text Transfer Protocol) works as a request and response protocol between a client and server. The entire World Wide Web uses this protocol.It was established in the early 1990's,almost everything you see in the browser is transmitted to your computer over HTTP.
A client(Browser)submits an HTTP request to the server,then the server returns a response to the client. The response contains status information about the request and may also contain the requested content.
HTTP Request:
An HTTP client sends an HTTP request to a server in the form of a request message.Now we will see the request message how it will look like:
The Request message contains 4 parts:
GET /Demo.html HTTP/1.1 -----------> Request Line
User-Agent:Mozilla/4.0
Host: www.interviewskills4u.blogspot.com
Accept-Language: en-us
Accept-encoding: gzip,deflate
connection:keep-alive
content-Length:35
In the above GET is nothing but method ,Demo.html is Request-URI and finally HTTP/1.1 is HTTP version. There are different methods are available such as POST,GET,PUT,DELETE,HEAD,CONNECT,OPTIONS,TRACE. There are different types of Request Header fields. The following are the some of the Request Header fields:
Accept-Encoding
Accept-Language
Authorization
User-Agent
...................
...................
etc.....
Next we will see entity-header fields. The following are the entity-header fields
Content-Length
Content-Encoding
Content-Type
........................
.......................
etc....
Next we will see General header fields. They are
Connection
Cache-control
Date
....................
.................
Http Response:
When the client(Browser) send HTTP request,then server response to the request back to the client. The Response message will look like below:
HTTP Response contains 4 parts they are
HTTP/1.1 200 OK
Date Thu,24,2016 12:25:56 GMT
Server: Apache/5.2(Win32)
Content-Length:88
Content-type:text/html
Connection:closed
The Response Header fields allow the server to pass additional information about the response which can not be placed in the status-line.There are different types of Response Header fields. They are
Age
Location
Accept-Ranges
ETag
..............
..............
etc.........
See also:
How cookies used in servlet
How to use doGet() and doPost() methods in servlet
TOP 20 Servlet Interview Questions
JSP Interview Questions
Servlet Life cycle
A client(Browser)submits an HTTP request to the server,then the server returns a response to the client. The response contains status information about the request and may also contain the requested content.
HTTP Request:
An HTTP client sends an HTTP request to a server in the form of a request message.Now we will see the request message how it will look like:
The Request message contains 4 parts:
- Request-line
- Request Headers(Zero or more headers)
- A blank line (It indicating the end of the header fields)
- Request message Body
GET /Demo.html HTTP/1.1 -----------> Request Line
User-Agent:Mozilla/4.0
Host: www.interviewskills4u.blogspot.com
Accept-Language: en-us
Accept-encoding: gzip,deflate
connection:keep-alive
content-Length:35
In the above GET is nothing but method ,Demo.html is Request-URI and finally HTTP/1.1 is HTTP version. There are different methods are available such as POST,GET,PUT,DELETE,HEAD,CONNECT,OPTIONS,TRACE. There are different types of Request Header fields. The following are the some of the Request Header fields:
Accept-Encoding
Accept-Language
Authorization
User-Agent
...................
...................
etc.....
Next we will see entity-header fields. The following are the entity-header fields
Content-Length
Content-Encoding
Content-Type
........................
.......................
etc....
Next we will see General header fields. They are
Connection
Cache-control
Date
....................
.................
Http Response:
When the client(Browser) send HTTP request,then server response to the request back to the client. The Response message will look like below:
HTTP Response contains 4 parts they are
- Status-line
- Response Headers
- A blank line
- A message body
HTTP/1.1 200 OK
Date Thu,24,2016 12:25:56 GMT
Server: Apache/5.2(Win32)
Content-Length:88
Content-type:text/html
Connection:closed
The Response Header fields allow the server to pass additional information about the response which can not be placed in the status-line.There are different types of Response Header fields. They are
Age
Location
Accept-Ranges
ETag
..............
..............
etc.........
See also:
How cookies used in servlet
How to use doGet() and doPost() methods in servlet
TOP 20 Servlet Interview Questions
JSP Interview Questions
Servlet Life cycle
No comments:
Post a Comment