简体   繁体   中英

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. 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. It always redirects to the restricted warning.

Any ideas why? I already checked url mapping on web.xml, should have no problem with that. I am guessing that because only this module have this http session in the servlet and jsp file.

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()

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");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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