简体   繁体   English

无法直接从url jsp / servlet访问页面

[英]cannot access page directly from url jsp/servlet

I have been given a task to troubleshoot this error on this existing web app and I am not familiar with jsp/servlet. 我已获得任务来解决此现有Web应用程序上的此错误,并且我对jsp / servlet不熟悉。 When a user logs in, he/she will be able to access all modules but there is one specific module that cannot be accessed directly from the url (when logically it should be able to) but if not directly from url, it can be accessed. 当用户登录时,他/她将能够访问所有模块,但是有一个特定模块不能直接从url访问(在逻辑上应该可以),但是如果不能直接从url访问,则可以访问。 It always redirects to the restricted warning. 它总是重定向到受限警告。

Any ideas why? 有什么想法吗? I already checked url mapping on web.xml, should have no problem with that. 我已经检查了web.xml上的url映射,对此应该没有问题。 I am guessing that because only this module have this http session in the servlet and jsp file. 我猜测是因为仅此模块在servlet和jsp文件中具有此http会话。

HttpSession RSession = request.getSession();
if(!"yesdirect".equals(RSession.getAttribute("vdirect"))){

    if(!"yesdirect".equals(request.getParameter("vdirect"))){
        response.sendRedirect("PermissionRestricted.jsp");
    }       
    else{
        RSession.setAttribute("vdirect", "yesdirect");  
    }
}

Any ideas or insight would be appreciated. 任何想法或见解将不胜感激。 Probably something is wrong in the codes or anything? 可能是代码有问题或什么错误?

Thank you. 谢谢。

please change the code with using toString() 请使用toString()更改代码

HttpSession RSession = request.getSession();
if (!"yesdirect".equals(RSession.getAttribute("vdirect").toString())) {

    if (!"yesdirect".equals(request.getParameter("vdirect").toString())) {
        response.sendRedirect("PermissionRestricted.jsp");
    } else {
        RSession.setAttribute("vdirect", "yesdirect");
    }
}

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

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