GWT会话管理 [英] GWT session management

查看:137
本文介绍了GWT会话管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有太多关于java的gwt会话。我对此有些怀疑。

I don't too much about gwt session on java. I've some doubts about it. Anyone can check if the implementation below is the way it needs to be done.

public class ServiceImpl extends RemoteServiceServlet implements Service  
{
   void CreateSession(String Username)
   {
      HttpServletRequest request = this.getThreadLocalRequest();
      HttpSession session = request.getSession();
      session.setAttribute("Username", Username);
   }

   boolean ValidateSession(String Username)
   {
       HttpServletRequest request = this.getThreadLocalRequest();
       HttpSession session = request.getSession();
       if (session.getAttribute("Username"))
       {
          return true;
       }
       return false;
   }
}

这是实现这两个函数的正确方法吗?

Is this the correct way to implement these two function???

推荐答案

几点修正

a few correction

    void createSession(String Username) {
        getThreadLocalRequest().getSession().setAttribute("Username", Username);
    }

    boolean validateSession(String Username) {
        if (getThreadLocalRequest().getSession().getAttribute("Username") != null) {
            return true;
        } else {
            return false;
        }
    }

这篇关于GWT会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆