我正在尝试弄清楚如何使用 cookie 来防止黑客将 URL 输入到 Java Web 应用程序的内部部分,除非用户登录,否则该应用程序不应被访问。
例如,我想阻止黑客输入 http://domain.com/myapp/listtable.jsp并且无需登录即可查看表格。
我有一个servlet,它存储了它分发给客户端的所有cookie 的列表。我正在努力理解 JSP/JSTL 代码会是什么样子来检查请求中的 cookie 并将其与服务器存储的内容进行比较。
类似于:
<c:forEach items="${cookie}" var="currentCookie">
<!-- Compare each incoming cookie with the cookies kept in the servlet,
if there's not a match then redirect to the login page. Otherwise,
show the contents of the page below -->
</c:forEach>
<html>
--- main page HTML here
有人可以给我一些关于如何做到这一点的建议吗?
最佳答案
关于java - 使用 JSTL 验证 JSP 中的 Cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6183971/