servlet 会话_在Servlet中管理会话
servlet 会话
在Servlet中管理会话 (Managing Session in Servlets)
We all know that HTTP is a stateless protocol. All requests and responses are independent. But sometimes you need to keep track of client's activity across multiple requests. For eg. When a User logs into your website, not matter on which web page he visits after logging in, his credentials will be with the server, until he logs out. So this is managed by creating a session.
我们都知道HTTP是无状态协议。 所有请求和响应都是独立的。 但是有时您需要跟踪多个请求中客户的活动。 例如。 当用户登录到您的网站时,无论登录后访问哪个网页,他的凭据都将保留在服务器中,直到注销为止。 因此,这是通过创建会话来管理的。
Session Management is a mechanism used by the Web container to store session information for a particular user. There are four different techniques used by Servlet application for session management. They are as follows:
会话管理是Web容器用于存储特定用户的会话信息的机制。 Servlet应用程序使用四种不同的技术进行会话管理。 它们如下:
- Cookies饼干
- Hidden form field隐藏表格栏位
- URL RewritingURL重写
- HttpSessionHttpSession
Session is used to store everything that we can get from the client from all the requests the client makes.
会话用于存储我们可以从客户端提出的所有请求中从客户端获得的所有内容。
会议的工作方式 (How Session Works)
The basic concept behind session is, whenever a user starts using our application, we can save a unique identification information about him, in an object which is available throughout the application, until its destroyed. So wherever the user goes, we will always have his information and we can always manage which user is doing what. Whenever a user wants to exit from your application, destroy the object with his information.
会话背后的基本概念是,每当用户开始使用我们的应用程序时,我们都可以将关于他的唯一标识信息保存在整个应用程序中可用的对象中,直到销毁为止。 因此,无论用户走到哪里,我们都将始终拥有他的信息,并且我们始终可以管理哪个用户在做什么。 每当用户想要退出应用程序时,请使用其信息销毁该对象。
翻译自: https://www.studytonight.com/servlet/session-management.php
servlet 会话