English 中文(简体)
获得当地重建(植被)永远无效。
原标题:getThreadLocalRequest().getSession(false) always null
  • 时间:2011-07-04 19:01:21
  •  标签:
  • java
  • gwt

i have some problems trying code login+cookies .. when the user is login i create the session

getThreadLocalRequest().getSession(true)

and when i want to check if session its still alive always return null

HttpSession session = getThreadLocalRequest().getSession(false);    
        if (session != null) {
           }

When i check the HttpRequest (when i check session alive) this have

Cookie: JSESSIONID=a1042a8e-9ebc-45b8-a3d8-12161885be96

and the cookie is ok.

我采用Eclipse+发展模式

服务器边代码:

public String login(String rut, String pass) throws AuthenticationException {
    //if UserPassMatch ...

session = this.getThreadLocalRequest().getSession(true);
    //set user bean 
session.setAttribute("beanSession", us);

HttpServletResponse response = getThreadLocalResponse();
Cookie usernameCookie = new Cookie("JSESSIONID", us.getSessionID());
usernameCookie.setPath("/");
usernameCookie.setMaxAge(60 * 60 ); //1 hora
response.addCookie(usernameCookie); 


}

@Override
public String checkIfSessionStillActive(String token) { 

HttpServletRequest request = getThreadLocalRequest();   
    //Here ALWAYS return null   
HttpSession session = request.getSession(false);

if (session != null) {
        //check sessionId and search User Bean 
}

    return token;
}

From client side nothing special just call checkIfSessionStillActive for check if session exists and go throw the token or go to login if it s not. When the user is logged in still return session NULL. I use MVP pattern and i call from AppController and i use the same rpcService. At once the user login i check session and its exists, but if i call checkIfSessionStillActive this not found any session. Really i read a lot of code and what i found its almost the same thing, ¿can any help me?

问题回答

您是否使用延伸远程服务单元的子级,在其他地方(例如春天)开立的物体,并推广远程服务。 如果是,解决你的问题

每项申请都设立了一个新的远程服务小组。 问题是,遥感超级类别中定义的现成地方变量不是静止的,因此,对每个物体而言,你有不同的变数。 当你在以上情况下处理时,你的要求反应现成当地变量,是接收对象的初始变量,但不是你援引某种方法的物体。

我利用工作方式,在援引第二个目标之前,先建立一个静态的校对,并设定了价值观。 现在沉积的物体也可以进入。

你们是否尝试使用固定标准,而不是直接使用 co子。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签