用session.putValue("User",username);
String User = (String)session.getValue("User");试试

解决方案 »

  1.   

    HttpSession session = request.getSession(true);
    session.removeAttribute("user");
    session.setAttribute("user","name");
      

  2.   

    楼上的:
    HttpSession session = request.getSession(true);
    上面这句编译出现问题,这句应该在servlet中才会用到,在jsp中session是隐藏的已经定义好了,不能重新定义。
    不是这个原因,不过谢谢你的回答!
      

  3.   

    楼上的:
    HttpSession session = request.getSession(true);
    上面这句编译出现问题,这句应该在servlet中才会用到,在jsp中session是隐藏的已经定义好了,不能重新定义。
    不是这个原因,不过谢谢你的回答!
      

  4.   

    我一直是用session.putValue("User",username);
    String User = (String)session.getValue("User");方法,在weblogic里面能用呀!那我无能为力了
      

  5.   

    按你的步骤,我怎么能得到SESSION 值啊?
    session.jsp<html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body bgcolor="#FFFFFF" text="#000000">
    <%@ page contentType="text/html; charset=gb2312" %>
    <%
    session.setAttribute("name","rocie");
    response.sendRedirect("rocie.jsp");
    %>
    </html>rocie.jsp<html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body bgcolor="#FFFFFF" text="#000000">
    <%@ page contentType="text/html;charset=gb2312" %>
    <%
    out.print(session.getAttribute("name"));
    %>
    </body>
    </html>
      

  6.   

    没有问题呀,我用resin,一切正常~~~~
      

  7.   

    这是不是跟webserver配置有关呢
    我看了一些资料,好像就像楼上几位
    说的一样,可是我光这样的例子就试过不下十次
    还是不行
    我还想问,设置session后,不管是从jsp->jsp->htm->jsp
    等等路径走下去以后,session还可以取得到呢?
    谢谢!
      

  8.   

    打开你的cookie
    或者用urlrewrite
      

  9.   

    <%@ page session="true" %>
    页首有没有这行语句啊
      

  10.   

    看你的code
    应该是忘了在每个jsp的页面的前面加上这句<%@ page session="true" %>
      

  11.   

    这儿!
    在浏览器的设置里打开cookie,也就是允许使用cookie!!!就不会出错了。