简体   繁体   English

会话和接口参数的隔离Java EE

[英]Isolation of sessions and interface parameters Java EE

we have a JavaEE Web application that runs on Tomcat5 server (jsp, java and extjs are used on development of this tool). 我们有一个在Tomcat5服务器上运行的JavaEE Web应用程序(此工具的开发中使用了jsp,java和extjs)。

We observe sometimes, particularly when the application is highly used, that some session variables or interface fields are mixed up in servlets . 有时,特别是在应用程序使用率很高的情况下,我们观察到某些会话变量或接口字段servlet 中混合在一起

This means that : when one user connects, his parameters are kept in the sessions. 这意味着:当一个用户连接时,其参数将保留在会话中。

After an update or insertion of data in the database ORACLE,the system returns the name of another user who was probably connected at the same time on a different navigator or a different computer. 在数据库ORACLE中更新或插入数据后,系统将返回可能同时连接到另一台导航器或另一台计算机上的另一个用户的名称。 Others times the request.getparameter gets a values from different clients or user interfaces . 其他时候,request.getparameter 从不同的客户端或用户界面获取 Thank you to help me fix this problem. 感谢您帮助我解决此问题。

The only way for this to happen is if you have a singleton somewhere that keeps track of the session and for some reason this singleton is mixing up the variables between sessions. 发生这种情况的唯一方法是,如果某个地方有一个单例跟踪会话,并且由于某种原因,这个单例混淆了会话之间的变量。

You can try this: Instead of differentiating a user only by its credentials (assuming you are not using Federation), return a token, unique amongst all sessions to the user logging in, and make the user send that unique id with every request. 您可以尝试以下操作:与其仅通过凭据来区分用户(假设您未使用联合身份验证),还可以向登录的用户返回在所有会话中唯一的令牌,并使用户在每次请求时都发送该唯一ID。 This way you will be able to differentiate the request/responses even if the user logs in using many different browsers. 这样,即使用户使用许多不同的浏览器登录,您也可以区分请求/响应。

But again, this will only happen when you do something like having a singleton connecting the session, by itself the session would not exchange variables amongst them. 但是同样,只有当您执行诸如使单例连接会话之类的操作时,这种情况才会发生,会话本身不会在它们之间交换变量。

I've finally understood how servlet.java works. 我终于了解了servlet.java的工作方式。 I works like main process that create a thread for any call thus, all attributes of such class are common to all thread and we are not sure of the result that we get when accessing them. 我的工作就像主进程一样,它为任何调用都创建了一个线程,因此,此类的所有属性对于所有线程都是通用的,我们不确定访问它们时得到的结果。

If we want any client to use those variables in a private context, we must put them in the function " doGet " or " doPost " as local variables. 如果希望任何客户端在私有上下文中使用这些变量,则必须将它们作为局部变量放入函数“ doGet ”或“ doPost ”中。

My problem have them been solved 我的问题解决了吗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM