0

会话在我的本地机器上运行,但是当我部署应用程序时,会话不起作用。

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。但是会话丢失了,当用户登录时我无法获取用户名。

4

1 回答 1

0

In GAE you have to activate session support, it's not enabled by default. Here is an official link:

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

于 2013-11-08T20:59:05.103 回答