当浏览器禁用Cookie时管理会话 [英] Manage Session when broswer has disable cookies
本文介绍了当浏览器禁用Cookie时管理会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,如果客户端浏览器已禁用cookie功能,我该如何管理会话.
I wants to know that How can i Manage Session if the client browser has disabled cookie feature..
如果我想在简单的JSP-Servlet中实现它,那我该怎么做?
If I wants to implement it in simple JSP - Servlet, then how can I do that ?
预先感谢...
推荐答案
在JSP端,您可以使用 <c:url>
.
In the JSP side, you can use JSTL's <c:url>
for this.
<a href="<c:url value="page.jsp" />">link</a>
那样容易.禁用Cookie时,它将自动添加jsessionid
.
Easy as that. It will automagically append the jsessionid
when cookies are disabled.
在Servlet端,您需要 HttpServletResponse#encodeRedirectURL()
为此.
In the Servlet side you need HttpServletResponse#encodeURL()
or -usually the preferred one inside Servlets- HttpServletResponse#encodeRedirectURL()
for this.
response.sendRedirect(response.encodeRedirectURL("page.jsp"));
这篇关于当浏览器禁用Cookie时管理会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文