• Post Reply Bookmark Topic Watch Topic
  • New Topic

Working of Web Container in Webserver  RSS feed

 
Aijaz Mallick
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a doubt that how does a Web-Server identifies a request coming from different Users or different Machines.

I am clear with the concept that when i login to my application with 2 different browsers i get 2 different session id's. But does web-server / web-container comes to know that the request is coming from different browser, different machine.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shorter answer - through HTTP Headers

long answer - HTTP stands for "Hypertext Transfer Protocol". HTTP headers are the core part of these HTTP requests and responses, and they carry information about the client browser, the requested page, the server and more.When you type a url in your address bar, your browser sends an HTTP request and it may look like this:

GET /test.html HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive


As mentioned above, browser sends Host as 127.0.0.1 and User Agent as Mozilla. So by reading these HTTP headers value, Web server finds the server and browser name.

~ abhay


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned above, browser sends Host as 127.0.0.1 and User Agent as Mozilla. So by reading these HTTP headers value, Web server finds the server and browser name.

Sorry, but this is just wrong enough that I need to correct it. "Host" is the name of the server - you must have copied these values from a request to a server running on your local machine. The server already knows which server it is, so no need to determine the server :-)

The server can look at two things to identify the client: the IP address (which is not part of the HTTP headers, since IP is a protocol on a lower level of the TCP/IP stack than HTTP), and cookies (which come in an HTTP header called "Cookie", and generally contain the session ID).
 
Aijaz Mallick
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, does it mean that by using these Headers Web-Server/Container identifies that it is a different browser or a complete new Host .. & so it generates a new Session ID ..??

Ohh if the above info is wrong that how does the Web server identifies that it is a New client as the IP address is not the part of HTTP headers ... so how the IP address is identified by the Web server.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would create a new session if there is none - so any time you access the server without sending a session ID, it will likely create a new one. This could happen if the browser in question has never accessed the server, or if the user has deleted the cookie, or if the cookie has expired.
 
Aijaz Mallick
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Reply..??
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, the IP address is part of the information transmitted via the IP protocol, not the HTTP protocol (and between those two is yet another protocol called TCP). How that works in detail can't be explained in a forum post; start reading here: TCP/IP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!