Map<String, HttpSession> map=(Map<String, HttpSession>) getServletContext().getAttribute("users");
来源:互联网 发布:泉州五中网络平台 编辑:程序博客网 时间:2024/06/05 10:21
package com.tfy.heima.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
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 KickServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String username=request.getParameter("username");
username=new String(username.getBytes("ISO-8859-1"),"UTF-8");
Map<String, HttpSession> map=(Map<String, HttpSession>) getServletContext().getAttribute("users");
HttpSession session=map.get(username);
if(session!=null){
session.removeAttribute("user");
map.remove(username);
}
out.write("踢出成功");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
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 KickServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String username=request.getParameter("username");
username=new String(username.getBytes("ISO-8859-1"),"UTF-8");
Map<String, HttpSession> map=(Map<String, HttpSession>) getServletContext().getAttribute("users");
HttpSession session=map.get(username);
if(session!=null){
session.removeAttribute("user");
map.remove(username);
}
out.write("踢出成功");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
- Map<String, HttpSession> map=(Map<String, HttpSession>) getServletContext().getAttribute("users");
- Map<String, HttpSession> map=(Map<String, HttpSession>) sc.getAttribute("users");//保存所有登录有关的map对象
- Map<String, HttpSession> map=(Map<String, HttpSession>)
- Map<String,String> map = new Hash<String,String>
- Map.Entry<String,String>
- c++ map<string,string>
- map<string, vector<string> >
- Map<String, Map<String, String>>转String,再转回Map
- map,string string string string string!!!!!!!!!
- Map<String, List> map=new HashMap<String,List>()
- Map<String, Object> map=new HashMap<String, Object>();
- Map<String, Object> map=new HashMap<String, Object>();
- velocity 循环Map<String,Map<String,Long>>
- Freemarker遍历map<String,Map<String,Object>>
- Map<String, String> map 遍历取值
- Map<String,String> m=new HashMap<String,String>()
- List<Map<String, String>> 转 Map<String, List<String>>
- List<Map<String,String>> 输出
- OpenCV_基于Laplacian算子的图像边缘增强
- Android的WiFi子系统架构
- 使用JS实现文件下载示例(asp.net)
- 面试程序员时的“唠叨”
- 又一个一月 / 2013年山大CS专业学位 / 二战 / 边工作边准备
- Map<String, HttpSession> map=(Map<String, HttpSession>) getServletContext().getAttribute("users");
- 详解ASP.NET MVC应用程序请求生命周期
- WIFI 介绍及其简单工作流程
- 英语单词词根——福利
- latex中单引号和负号等一些小细节问题
- lua 热更新
- JBoss、Geronimo及Tomcat比较分析
- hdu 3234 Exclusive-OR
- 基础加强_动态代理及AOP