【发布时间】:2026-02-10 11:00:01
【问题描述】:
我有一个使用我的 GAE 应用程序的 JSP 应用程序。这个 JSP 应用程序是我的移动界面。
我想在内存缓存(会话)中存储一些值。我的意思是,当我打开一个 JSP 文件时,我调用了我的 GAE 应用程序并存储了这个值。
我不知道如何存档。
我已经创建了这个方法(在我的 GAE 应用程序中)从我的 JSP 文件中调用,但是我在 this.getThreadLocalRequest() 上得到了一个空点。
public void setTimezoneSession(String timezone){
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession(true);
// Here is where I try to set timezone in memcache (session)
session.setAttribute("timezone", timezone);
}
在我的 JSP 文件中,我调用了 AJAX:
$.ajax({
type: "post",
url: "TimeZone.jsp",
data: "tz_cliente=" + "Europe/Madrid",
cache: false,
success: function (msg) {}
});
TimeZone.jsp 是这个文件:
<%
// Here I get "Europe/Madrid" from AJAX.
String tz = (String)request.getParameter("timezone_from_ajax");
userService.setTimezoneSession(tz);
%>
怎么了?
谢谢你, 迭戈。
【问题讨论】:
标签: java jsp google-app-engine session