你用得不对!
应该这样写
在同一个servlet里
HttpSession mysesion=request.session();
mysession.setAttribute("username",username);然后再
String kjk= (String )mysesion.getAttribute("username");如果在jsp 中用,是这样写
session.getAttribute("username");
就行了

解决方案 »

  1.   

    HttpSession mysesion=request.getSession();
      

  2.   

    HttpSession mysesion=request.getSession();  //ok
      

  3.   

    你在JSP里面直接用好了,
    session.set......(String)session.get....不要定义HttpSession丢丢
      

  4.   

    在servlet 中
    request.getSession().setAttribute("username",username);
      

  5.   

    谢谢大家!搞定!
    应该是:
    在同一个servlet里
    HttpSession mysesion=request.getSession();
    mysession.setAttribute("username",username);然后再
    String kjk=mysession.getAttribute("username").toString();
    ok!