📄 chat.java
字号:
package chatroom;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
/**
* Title: JSP聊天室
* Description: Java语言演示程序:JSP聊天室,用于北京师范大学计算机系Java课程教学示范。
* Copyright: Copyright (c) 2002
* Company: 北京师范大学计算中心
* @author 张庆利
* @version 1.0
*/
public class Chat extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException{
response.setContentType("text/html;charset=gb2312");
String thisMySpeaking=new String(request.getParameter("txtword").getBytes("ISO-8859-1"),"GB2312");
String thisTargetUserId=request.getParameter("seluser");
String thisColor=request.getParameter("selcolor");
String thisFace=request.getParameter("selface");
String selRe1=request.getParameter("selre1");
String selRe2=request.getParameter("selre2");
String thisRadprivate=request.getParameter("radprivate");
if (thisRadprivate==null) thisRadprivate=new String("no");
HttpSession session=request.getSession(true);
oneUser thisUser=(oneUser)session.getAttribute("thisUser");
String thisSourceUserId=thisUser.getUserId();
String thisSourceUserName=thisUser.getUserName();
int intChatroom=Integer.parseInt(thisUser.getUserPosion());
ServletContext application=getServletContext();
ChatRoom thischatroom=(ChatRoom)application.getAttribute("thischatroom");
int retimeuser=Integer.parseInt(selRe2);
int retimechat=Integer.parseInt(selRe1);
thisUser.setRetimeUser(retimeuser,intChatroom);
thisUser.setRetimeChat(retimechat,intChatroom);
String thisTargetUserName=thischatroom.returnUserName(intChatroom,thisTargetUserId);
thischatroom.addSpeaking(thisMySpeaking,thisSourceUserId,thisTargetUserId,thisSourceUserName,thisTargetUserName,thisFace,thisColor,thisRadprivate,intChatroom);
getServletConfig().getServletContext().getRequestDispatcher("/mytest/jsp/onechat.jsp").forward(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException{
doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -