Flash 范围是否不受竞争条件影响?

发布于 2024-11-15 22:46:45 字数 413 浏览 2 评论 0原文

我发现 JSF 2.0 Flash 范围是通过 cookie 在 Mojarra 2.x 中实现的。似乎发生的情况是,当使用 Flash 从视图 A 导航到视图 B 时,JSF 会发送重定向响应。正是这个相同的响应包含 set-cookie 标头。

由于 cookie 对于浏览器来说是全局的,我想知道这导致竞争条件的可能性有多大。由于 cookie 是在重定向响应期间设置的,因此我尝试查找 HTTP 规范是否以某种方式保证浏览器响应时发出的请求始终是第一个使用此 cookie 的请求。

然而,一般来说,如果第一个请求以某种方式停滞(因为互联网决定将该特定请求路由到半个地球),然后来自另一个选项卡的第二个请求首先到达服务器,则可能仍然存在问题。

将 cookie 用于两个页面之间的 flash 范围不是一个糟糕的主意,还是我忽略了某些东西并且它完全安全吗?

I found out that the JSF 2.0 Flash scope is implemented in Mojarra 2.x via a cookie. What seems to happen is that when navigating from view A to view B using The Flash, JSF sends a redirect response. It is this same response that contains the set-cookie header.

As cookies are global for the browser, I wonder what the chances are that this leads to a race condition. As the cookie is set during the redirect response, I tried to find if the HTTP spec somehow guarantees that the request that the browser issues in response is always the first to utilize this cookie.

In general however, there might still be a problem if this first request is somehow stalled (since the Internet decided to route that particular request half way around the world), and then a second request originating from another tab arrives at the server first.

Isn't a cookie a terrible idea to use for a flash scope between two pages, or am I overlooking something and is it perfectly safe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫以 2024-11-22 22:46:45

如果有资源,例如文件或 cookie...当然,总会有机会出现竞争条件。但你应该调查一下如何避免它。

我认为完美保存它的答案是EJB 3.0
我们使用 EJB 3.0 因为事务安全。
就像我们向 EJB 传递请求以在数据库中插入数据一样,您可以使用 EJB 作为协商者与 Flash 作用域进行交互。这样您的交易将得到保护,这意味着您将没有竞争条件风险。

If there is resource, such as a file or, cookie... for sure, there will always be a chance to be a race condition. But you should investigate, how to avoid it.

I think the answer to have it perfectly save are EJB 3.0
We use EJB 3.0 because are transactional safe.
In the same way we pass a request to an EJB to insert data in a database, you can interact with your flash scope using an EJB as a negociator. That way your transaction will be secured and that means you will be race conditon risk free.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文