HttpSessionBindingListener监听器里面的二个方法倒底什么时候触好啊? HttpSession.putValue()和removeValue()都是Deprecated的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //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> 相关文档:http://edocs.bea.com/wls/docs81/webapp/app_events.html 关于将图片保存到word中,之后将word导出的问题 弱弱的问句,XML页面可以编辑吗? ORACL + Hibernet 乱码问题 初学EJB的问题,请前辈帮忙 弱弱的问一下~~ 现在到了一个困惑期!请高人指点一下方向! BEA Weblogic哪里有下载? 如何启动Apache Server 2.0.47?? 关于调用EJB的问题! java+xml异构数据交换系统实现方案,大家来提提意见 WebLogic8.1怎么启动不了呢? jsp页面中字的长度控制的问题。
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>
http://edocs.bea.com/wls/docs81/webapp/app_events.html