你应该使用的是HttpSession吧。
如果是:
 HttpSession theSession;
 //.....
  theSession..getServletContext().setAttribute("","");
别的协议就不知道了。