Jsp 请求转发到GWT托管页面不工作

Jsp 请求转发到GWT托管页面不工作,jsp,servlets,gwt,httprequest,httpresponse,Jsp,Servlets,Gwt,Httprequest,Httpresponse,我已经用html创建了一个登录页面,它将表单提交给servlet(LoginServlet) 成功进行身份验证后,我将请求转发到一个gwtPage.jsp,该gwtPage.jsp加载nocache.js脚本 方法1: 下面是我的LoginServlet代码 request.setAttribute("loginId",loginId); dispatcher = request.getRequestDispatcher("gwtPage.jsp"); dispatcher.forward(re

我已经用html创建了一个登录页面,它将表单提交给servlet(LoginServlet)

成功进行身份验证后,我将请求转发到一个gwtPage.jsp,该gwtPage.jsp加载nocache.js脚本

方法1: 下面是我的LoginServlet代码

request.setAttribute("loginId",loginId);
dispatcher = request.getRequestDispatcher("gwtPage.jsp");
dispatcher.forward(request, response);
在我的gwtPage中,我包含了以下脚本

<script type="text/javascript" language="javascript" src="pc/pc.nocache.js?<%= new Date()%>"></script>
它恰当地指向 但是,我无法发送隐藏属性(我不想通过URL参数传递)


请为我的方法提供一些建议。欢迎任何想法。

没有“隐藏属性”这样的东西——它可以很容易地提取和伪造。如果要使其安全,需要使用会话。工作流程非常简单:

  • 对LoginServlet中的用户进行身份验证。将身份验证令牌(如loginId)保存到会话

    HttpSession session = request.getSession(true);
    session.setAttribute("login", loginId);
    
  • 将用户重定向到应用程序页面

    response.sendRedirect("/gwtPage.jsp");
    
  • 在此JSP中,从会话检索身份验证令牌。如果不存在,请重定向回登录页面。如果存在,请继续加载应用程序

    HttpSession session = request.getSession(true);
    if (session == null || session.getAttribute("login") == null) {
        response.sendRedirect("/Login.jsp");
    }
    
    确保服务器上已启用会话


  • 您是否尝试过使用浏览器的开发工具来查看使用方法1时网络请求/响应的结果?对于方法1,它只加载gwtPage.jsp,而不加载div上的GWT模块。
    HttpSession session = request.getSession(true);
    if (session == null || session.getAttribute("login") == null) {
        response.sendRedirect("/Login.jsp");
    }