HttpSession.putValue()和removeValue()都是Deprecated的。

解决方案 »

  1.   

    //MySessionListener.javapackage com.yan;import javax.servlet.http.HttpSessionAttributeListener;
    import javax.servlet.http.HttpSessionBindingEvent;public class MySessionListener implements HttpSessionAttributeListener { public void attributeAdded(HttpSessionBindingEvent arg0) {
    System.out.println("attributeAdded"); } public void attributeRemoved(HttpSessionBindingEvent arg0) {
    System.out.println("attributeRemoved"); } public void attributeReplaced(HttpSessionBindingEvent arg0) {
    System.out.println("attributeReplaced"); }}
    //web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <listener>
    <listener-class>com.yan.MySessionListener</listener-class>
    </listener></web-app>
    //MyJsp.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'MyJsp.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
        This is my JSP page. <br>
        <%
       //session.setAttribute("aaa","AAA");
       session.setAttribute("SSSSSSS",new Vector());
       // session.removeAttribute("aaa");
    //session.getSessionContext();
    //session.setMaxInactiveInterval(0);
       session.invalidate();
       %>
        
      </body>
    </html>
      

  2.   

    相关文档:
    http://edocs.bea.com/wls/docs81/webapp/app_events.html