Tomcat 如何处理多个请求 [英] How Tomcat handles multiple requests

查看:47
本文介绍了Tomcat 如何处理多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道创建 Web 应用程序,但我有一个基本疑问.

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.

Tomcat Container 如何处理请求,我的意思是说,当我发送对 home.jsp 页面的请求时,我得到的响应只是 home.jsp 页面而不是register.jsp 页面,该页面同时可能是来自世界其他角落的其他人的请求.

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.

例如:

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)

在这种情况下,Tomcat 如何不混淆请求者和对正确请求者的响应.

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.

谢谢.

推荐答案

你基本上是在问 TCP 是如何工作的.这是一个相当大的主题.基本上,它可以按原样恢复:Tomcat 侦听给定 TCP 端口(默认为 8080)上的连接.每次某些浏览器打开到 Tomcat 的连接时,该连接由远程主机的 IP 地址和该主机用于连接到 Tomcat 的 TCP 端口标识.

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.

浏览器通过此连接发送 HTTP 请求,当请求进入 Tomcat 时,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.

TCP 栈本身不是由 Tomcat 实现的,而是由 OS 实现的.Java 运行时提供 java.io.Socket 和其他相关类,这些类使用操作系统提供的底层 TCP IP 堆栈.并且 Tomcat 依赖于 java.net.Socket 和其他相关的类.

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.

这篇关于Tomcat 如何处理多个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆