⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chatroomlogindo.java

📁 一个bbs论坛系统
💻 JAVA
字号:
package com.lovo.servlet;

import java.io.IOException;
import java.util.ArrayList;
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;

import com.lovo.po.UserPO;

public class ChatroomLoginDO extends HttpServlet{

	private static final long serialVersionUID = -7459877701820700595L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		response.setCharacterEncoding("utf-8");
		HttpSession session=request.getSession();
		ServletContext application=this.getServletContext();
		
		String loginChatroomUser=((UserPO)session.getAttribute("user")).getName();
		String chatroomName=request.getParameter("chatroomName");
		session.setAttribute("chatroomName", chatroomName);
		
		List<String> loginChatroomUserList=(List<String>)application.getAttribute(chatroomName+"loginChatroomUserList");
		if(loginChatroomUserList==null){
			loginChatroomUserList=new ArrayList<String>();
			application.setAttribute(chatroomName+"loginChatroomUserList", loginChatroomUserList);
		}
		if(loginChatroomUserList.indexOf(loginChatroomUser)==-1){
			loginChatroomUserList.add(loginChatroomUser);
		}
		response.sendRedirect("web/jsp/chatroom.jsp");
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -