对session操作有个 removeValue
的操作,他是做什么用的?

解决方案 »

  1.   

    request.getSession().setAttribute("sessionName",null);
    试试。
      

  2.   


    request.getSession().removeAttribute("sessionName") ;
      

  3.   

    我另建了一个注销页面,再里面进行注销,执行如下代码:
    <%@ page contentType="text/html;charset=gb2312" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>注销</title>
    </head>
    <%@ page language="java" import="java.sql.*" %>
    <%
    request.getSession().setAttribute("banjis",null);
    request.getSession().setAttribute("num",null);
    request.getSession().setAttribute("name",null);
    request.getSession().setAttribute("times",null);
    request.getSession().setAttribute("dwnsubject",null);
    //String banji1=(String) session.getValue("banjis");
    //out.print(banji1);%>
    <body>
    <script language=javascript>
      window.location="index.jsp";
    </script>
    </body>
    </html>
    %>
    <body>
    <script language=javascript>
      window.location="index.jsp";
    </script>
    </body>
    </html>
    在这个面中,我out.print(banji1);的值为null,可是当我用另外一个人登陆时仍旧得到的哪个结果!!!
      

  4.   

    gzwrj  ,你那个函数该怎么用呢?详细点好吗,谢谢!
      

  5.   

    response.setHeader("pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Cache-Control", "no-store");
    加这个试试。
      

  6.   

    invalidate
    public void invalidate()
    Invalidates this session then unbinds any objects bound to it.
    Throws:
    IllegalStateException - if this method is called on an already invalidated session
      

  7.   

    问:但是到登陆进去之后,刷新一下就没有问题,怎么回事呢?
    答:试试这个
    <script language=javascript>
      window.location="index.jsp?time=<%=System.currentTimeMillis()%>";
    </script>
      

  8.   

    times2001你的我用了之后就反复的闪个不停,怎么回事,我只想让他在打开页面时刷新一次,能帮看看吗?
      

  9.   

    gzwrj你说的我还是不太懂,呵呵,请原谅我这个菜鸟,在详细说说好吗,包括用法,和用的地方!!!!
    andrawu你的我用了,不知道地方对不对,也没有作用啊!
    要不然你们看看怎么样是得打开页面后能自动刷新一次!
    谢谢你们提供的支持!!
      

  10.   

    http://www.csdn.net/expert/topic/765/765120.xml?temp=.9400904
      

  11.   

    <script language=javascript>
      window.location="index.jsp?time=<%=System.currentTimeMillis()%>";
    </script>这个不要放在index.jsp里面就可以了
      

  12.   

    我想我的是不是和  chinaren的情况差不多,他也要注销,
    注销的页面我是这样的:<%@ page contentType="text/html;charset=gb2312" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>注销</title></head>
    <%@ page language="java" import="java.sql.*" %>
    <%
    request.getSession().setAttribute("banjis",null);
    request.getSession().setAttribute("num",null);
    request.getSession().setAttribute("name",null);
    request.getSession().setAttribute("times",null);
    request.getSession().setAttribute("dwnsubject",null);
    request.getSession().setAttribute("code",null);//String banji1=(String) session.getValue("banjis");
    //out.print(banji1);
            response.setHeader("pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Cache-Control", "no-store");
    %>
    <body>
    <script language=javascript>
      window.location="password.jsp";
    </script>
    </body>
    </html>
      

  13.   

    index.jsp 页面里有个“注销”,点“注销”后交给另一个页面(例如:dis.jsp)处理注销过程,处理完注销后用
    <script language=javascript>
      window.location="index.jsp?time=<%=System.currentTimeMillis()%>";
    </script>
    返回index.jsp如有问题再一起研究
      

  14.   

    times2001我是用你的代码把注销后捣回到登陆也面的,
    但我在次登陆到哪个也面后,我发现里面的值还显示在那里,但是,刷新一下就好了,真是奇怪!
      

  15.   

    login out的时候.
            HttpSession session = request.getSession(true);
            session.invalidate();
    在你jsp根目录.加上一个index.html
    指向你的loing page.
      

  16.   

    一件很不可能的原因是:清空session需要时间
    虽然这个原因不可能,但是你可以试试延迟两秒后返回index.jsp
    <script language="Javascript">
    mytimeout=setTimeout("self.location ='index.jsp?Time=<%=System.currentTimeMillis()%>'",2000);
    </script>
      

  17.   

    times2001延时不起作用啊,
    qzwrj,谢谢你的耐心,我是这样用你给的代码做的,首先我在我的哪个loginconfirm里加了HttpSession session = request.getSession(true);
            session.invalidate();
    然后有在页面里建index.html(这块不知道是做什么用的),结果还是没有改变啊!
    还是不行,我这个问题快一天了,头都大了,我做在电脑前基本上没动啊,真惨:)
    那能不能就使页面打开后自动刷新一次呢?