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

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

问题描述

我知道创建网络应用程序,但我有一个基本的疑问。



我很抱歉提出非常愚蠢的问题,但我想澄清我的怀疑。 / p>

Tomcat容器如何处理请求,我的意思是当我发送 home.jsp 页面的请求时,我得到的响应为仅限home.jsp 页面,而不是 register.jsp 页面,该页面同时可能是来自世界其他角落的其他人提出的请求。



例如:

 客户A --------请求(a.jsp) )----------> Tomcat(检查a.jsp请求并向客户端A提供正确的a.jsp响应)

客户端B --------请求(b.jsp)------ ----> Tomcat(检查b.jsp的请求并向客户B提供适当的b.jsp响应)

In在这种情况下,Tomcat如何在请求者和对正确请求者的响应之间不会混淆。



内部如何工作。



解释这一点的一些链接也会有所帮助。



谢谢。

解决方案

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



浏览器通过此连接发送HTTP请求,当请求进入Tomcat时,Tomcat会从其线程池中分配一个线程来处理请求。当生成并发送响应时,线程返回池,准备从任何客户端提供另一个请求。



Tomcat不实现TCP堆栈本身,但由操作系统。 Java运行时提供java.io.Socket和其他相关类,它们使用操作系统提供的底层TCP IP堆栈。 Tomcat依赖于java.net.Socket和其他相关类。


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.

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

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