Auth Session Servlet Java JSP

时间:2019-03-30 01:27:42

标签: java jsp

我总是在下面的代码中转到ELSE语句:

if (session == null) {

            request.setAttribute("stts_log", "Login");
            request.setAttribute("btn_modal", "exambutton");
            request.setAttribute("btn_href", "#");
            out.print("Please login first");  
            RequestDispatcher rd=request.getRequestDispatcher("index2.jsp");  
            rd.forward(request, response); 

        } else {
            request.setAttribute("sess", session);
            request.setAttribute("stts_log", "Logout");
            request.setAttribute("btn_modal", "");
            request.setAttribute("btn_href", "ControllerServlet");
            RequestDispatcher rd=request.getRequestDispatcher("index2.jsp");  
            rd.forward(request, response); 
        }

0 个答案:

没有答案