确定你向session对象中添加的对象hb_file不是null.

解决方案 »

  1.   

    用这个试试应该可以的
    HttpSession hb_session = request.getSession(true);
      

  2.   

    我开始就是用楼上说的用法,不行我才改为了
    HttpSession hb_session = request.getSession();结果还不行
      

  3.   

    Hashtable[] hb_data = (Hashtable[])hb_session.getAttribute("hb_file");
    那就是Hashtable[]的问题了啊
    其他地方真看不出来有什么错误~~
      

  4.   

    HashTable做一個數組?沒搞錯吧,第一次看到呢
      

  5.   

    没搞错,就是做一个数组,并将数组以session形式传递给另一个函数。但我想在另外两个地方获取到,但出粗了。
      

  6.   

    HttpSession hb_session = httpRequestServlet.getSession();
    hb_session.setAttribute("hb_file", hb_file);
    (类型)hb_file=(类型)session.getAttribute("hb_file");
    看看是否为空
      

  7.   

    HttpSession hb_session = httpServletRequest.getSession();
    hb_session.setAttribute("hb_file", hb_file);
    (类型)hb_file1=(类型)session.getAttribute("hb_file");
    看看是否为空
      

  8.   

    你不应该在同一ACTION中,你至少要让它的请求发出去,它才会对SESSION附值啊
      

  9.   

    HttpSession hb_session = httpServletRequest.getSession();
    应该是HttpSession hb_session = HttpServletRequest.getSession();
    然后,建议采用HttpSession hb_session = HttpServletRequest.getSession(true);这样就保证了如果没有session存在,那么就创建一个。还有,如果在同一页面既setAttribute("key",value);又getAttribute("key");这样是不行的,session不是客户端维护的。你至少要通过一次和服务器交互,让服务器知道你对session做了操作才是啊!建议,每次操作session之前用isNew()判断一下。
      

  10.   

    你调试一下,session不必存取不必在两个页面,cookie才那样
      

  11.   

    还是不行,我想把同一个变量的值放在同一个session变量的不同字符串变量中,例如:
    HttpSession hb_session = request.getSession(true);
    hb_session.setAttribute("hb_file", hb_file);
    hb_session.setAttribute("hb_display", hb_file);现在想在使用完第一个“hb_file”后将其失效,而第二个“hb_display”,仍然可以通过使用
    session.getAttribute("hb_display")获取到该怎么办?
    急急急急啊
      

  12.   

    yulchina() 说的有理,学习中