在JavaScript中替换httpservletrequest.getSession()
当前,我们正在使用旧应用程序,其中java httpservletrequest.getsession()函数从浏览器的父级选项卡中设置了会话的客户端浏览器中获取会话。
现在,我们需要访问相同的会话信息[例如,我们在会话中已有令牌] 使用我们的新应用程序与分离的微服务体系结构[UI-REACT JS]。 我们是否能够从前端访问会话?
感谢您对此的建议。
谢谢 !
Currently, we are using a legacy application where the Java HttpServletRequest.GetSession() function to get the session from the Client browser where the session is set from the Browser's parent tab.
Now we need to access the same session information [example, we have Token in the session]
using our new application with decoupled Microservice architecture [ UI-React JS].
Whether we can able to access the session from Front End?
Appreciate your suggestion on this.
Thank you !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP会话是后端的临时商店,您可以根据先前的请求存储东西。一旦您将某些东西存储在此处,后端就会将Set-Cookie标头返回到浏览器,并使用jsessionID浏览器存储给用户。对于下一个呼叫,浏览器将发送相同的jsessionId cookie,后端将其用作检索该用户浏览器先前保存的数据的键。
如果您要迁移到React JS应用程序,我认为无需在后端存储令牌,而是将仅使用JSessionId的Cookie使用。相反,前端可以存储所有必要的数据客户端。
我认为有多种选择:
The HTTP Session is a temporary store in the backend, where you store something based on previous requests. As soon as you store something there, the backend will return a Set-Cookie header to the browser with a JSESSIONID that the browser stores for the user. For the next calls, the browser will send the same JSESSIONID cookie, and the backend will use it as a key to retrieve the previously saved data for that user's browser.
If you're migrating to a React JS application, I think there's no need to store tokens in the backend, and use cookies with only JSESSIONID in. Instead, the frontend can store all the necessary data client-side.
I think there's multiple options: