首页>代码>java HttpSessionListener实现对在线用户的精确统计>/onlineUserCounter/src/com/kaka/servlet/LogoutServlet.java
package com.kaka.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LogoutServlet extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	@SuppressWarnings("unchecked")
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HttpSession session = req.getSession();
		String userName = (String) session.getAttribute("username");
		session.invalidate();//session失效
		ServletContext application = session.getServletContext();
		List<String> userList = (List<String>) application.getAttribute("userlist");
		userList.remove(userName);
		resp.sendRedirect("result.jsp");
		
		
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		doPost(req, resp);
		
	}
}
最近下载更多
JiangYing009  LV7 2023年11月16日
wubinbin  LV11 2022年5月25日
随风者  LV3 2022年2月2日
895919265  LV1 2022年1月24日
kay523393  LV2 2021年10月8日
breakCY  LV15 2021年8月18日
yawhaaa  LV1 2021年3月23日
炤杰爱玩代码菌  LV1 2020年11月17日
jifang  LV1 2020年10月28日
不是菜鸡是蔡文姬  LV2 2020年9月25日
最近浏览更多
JiangYing009  LV7 2023年11月16日
weilaizhisheng  LV21 2023年1月9日
18356557758  LV5 2022年7月10日
locklock  LV2 2022年6月24日
wubinbin  LV11 2022年5月25日
yanguobin  LV4 2022年5月3日
taoshen95  LV14 2022年3月14日
随风者  LV3 2022年2月2日
895919265  LV1 2022年1月24日
silencecfx  LV1 2021年12月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友