部署应用程序引擎时会话无效

时间:2013-11-08 20:29:09

标签: java google-app-engine gwt

会话正在我的本地计算机上运行但是当我部署应用程序时,会话无法正常工作。

protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException 
{
     String UserName = req.getParameter("username");
     HttpSession request = req.getSession();
     request.setAttribute("UserName", UserName);
     request.setAttribute("Reload", "true");
     res.setHeader("Content-Type", "text/html");
     //http://demoapp04071992.appspot.com/
     //res.sendRedirect("http://127.0.0.1:8888/FileSharingDemo.html?gwt.codesvr=127.0.0.1:9997");
     res.sendRedirect("http://demoapp04071992.appspot.com/FileSharingDemo.html");
}

当我在本地运行时,我使用url 127.0.0.1。当我部署时,我使用url demoapp04071992。但会话丢失,用户登录时无法获取用户名。

1 个答案:

答案 0 :(得分:0)

在GAE中,您必须激活会话支持,默认情况下不启用它。这是官方链接:

https://developers.google.com/appengine/docs/java/config/appconfig?csw=1#Java_appengine_web_xml_Enabling_sessions

相关问题