I am aware of creating web application but there is one basic doubt I have.
I am sorry for asking very silly question but want to clear my doubt.
How Tomcat Container handle request, I mean to say when I send a request for home.jsp page then I get the response as home.jsp page only and not a register.jsp page which at the same time might be the request given by other person requested from other corner of the world.
Eg:
Client A --------request(a.jsp)----------> Tomcat (check request received for a.jsp and give proper a.jsp response to client A)
Client B --------request(b.jsp)----------> Tomcat (check request received for b.jsp and give proper b.jsp response to client B)
In this case, how does Tomcat not get confused between requester and response to correct requester.
How it works internally.
Some links which explain this will also be helpful.
Thanks.
You're basically asking how TCP works. Which is quite a large subject. Basically, it can be resumed as is: Tomcat listens for connections on a given TCP port (8080 by default). Each time some browser opens a connection to Tomcat, this connection is identified by the IP address of the remote host, and by the TCP port used by this host to connect to Tomcat.
A HTTP request is sent by the browser over this connection, and when the request comes in to Tomcat, Tomcat assigns a thread from its pool of threads to handle the request. When the response has been generated and sent, the thread goes back to the pool, ready to serve another request from any client.
The TCP stack itself is not implemented by Tomcat, but by the OS. The Java runtime provides java.io.Socket and other related classes, which use the underlying TCP IP stack provided by the OS. And Tomcat relies on java.net.Socket and the other related classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With