UML课程设计java web网上聊天室


UML课程设计(java web网上聊天室附源码)
资源截图
代码片段和文件信息
package cx.action;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

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

import org.apache.commons.beanutils.BeanUtils;

import cx.bean.User;
import cx.service.UserService;
import cx.utils.baseServlet;


public class UserServlet extends baseServlet {
/**
 * 检查session是否过期
 * @throws IOException 
 */
public String check(HttpServletRequest reqHttpServletResponse resp) throws IOException{

User existUser = (User) req.getSession().getAttribute(“existUser“);
if(existUser == null){
resp.getWriter().println(“1“);
}else{
resp.getWriter().println(“2“);
}
return null;
}

/**
 *  退出聊天室
 * @throws IOException 
 */
public String exit(HttpServletRequest requestHttpServletResponse response) throws IOException{
HttpSession session = request.getSession();
session.invalidate();
response.sendRedirect(request.getContextPath()+“/index.jsp“);
return null;
}

/**
 * 发送聊天内容
 * @throws IOException 
 */
public String sendMessage(HttpServletRequest reqHttpServletResponse resp) throws IOException{

System.out.println(“sendMessage invoke....“);
String from = req.getParameter(“from“); // 发言人
String face = req.getParameter(“face“); // 表情
String to = req.getParameter(“to“); // 接收者
String color = req.getParameter(“color“); // 字体颜色
String content = req.getParameter(“content“); // 发言内容
// 发言时间 正常情况下使用SimpleDateFormat
String sendTime = new Date().toLocaleString(); // 发言时间
ServletContext application = getServletContext();
String sourceMessage = (String) application.getAttribute(“message“);
// 拼接发言的内容:xx 对 yy 说 xxx
sourceMessage += ““ + from
+ “
“ 
+ “对[“ + to + “]说:“
+ ““ + content + face+ “(“
+ sendTime + “)
“;
application.setAttribute(“message“ sourceMessage);
return getMessage(req resp);
}

/**
 * 获取消息的方法
 * @throws IOException 
 */
public String getMessage(HttpServletRequest reqHttpServletResponse resp) throws IOException{
String message = (String) getServletContext().getAttribute(“message“);
if(message != null){
resp.getWriter().println(message);
}
return null;
}
/**
 * 踢人的功能
 * @throws IOException 
 */
public String kick(HttpServletRequest reqHttpServletResponse resp) throws IOException{
int id = Integer.parseInt(req.getParameter(“id“));
Map userMap = (Map) getServletContext()
.getAttribute(“userMap“);
User user = new User();
user.setId(id);
HttpSession session = userMap.get(user);
session.invalidate();
resp.sendRedirect(req.getContextPath()+“/main.jsp“);
return null;
}

/**
 * 登录的功能

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-06-26 19:26  UML
     文件     2056917  2015-06-26 19:26  UMLUML.doc
     目录           0  2015-06-26 19:23  UMLchatroom
     文件         529  2015-04-19 20:12  UMLchatroom.classpath
     目录           0  2015-06-26 19:27  UMLchatroom.myeclipse
     文件         312  2015-06-11 09:18  UMLchatroom.mymetadata
     文件        1756  2015-06-11 09:17  UMLchatroom.project
     目录           0  2015-06-26 19:23  UMLchatroom.settings
     文件         500  2015-04-19 20:12  UMLchatroom.settings.jsdtscope
     文件        1009  2015-06-11 09:18  UMLchatroom.settingscom.genuitec.eclipse.j2eedt.core.prefs
     文件         364  2015-04-19 20:12  UMLchatroom.settingsorg.eclipse.jdt.core.prefs
     文件         106  2015-06-11 09:19  UMLchatroom.settingsorg.eclipse.ltk.core.refactoring.prefs
     文件         477  2015-06-11 09:19  UMLchatroom.settingsorg.eclipse.wst.common.component
     文件         252  2015-04-19 20:12  UMLchatroom.settingsorg.eclipse.wst.common.project.facet.core.xml
     文件          49  2015-04-19 20:12  UMLchatroom.settingsorg.eclipse.wst.jsdt.ui.superType.container
     文件           6  2015-04-19 20:12  UMLchatroom.settingsorg.eclipse.wst.jsdt.ui.superType.name
     目录           0  2015-06-26 19:23  UMLchatroomWebRoot
     目录           0  2015-06-26 19:23  UMLchatroomWebRootCSS
     文件         960  2015-04-19 20:12  UMLchatroomWebRootCSSstyle.css
     目录           0  2015-06-26 19:23  UMLchatroomWebRootmeta-INF
     文件          36  2015-04-19 20:12  UMLchatroomWebRootmeta-INFMANIFEST.MF
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INF
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INFclasses
     文件         336  2015-04-19 20:27  UMLchatroomWebRootWEB-INFclassesc3p0-config.xml
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INFclassescx
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INFclassescxaction
     文件        4870  2015-06-11 10:21  UMLchatroomWebRootWEB-INFclassescxactionUserServlet.class
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INFclassescxean
     文件        2782  2015-06-11 09:18  UMLchatroomWebRootWEB-INFclassescxeanUser.class
     目录           0  2015-06-26 19:23  UMLchatroomWebRootWEB-INFclassescxdao
     文件         151  2015-06-11 09:18  UMLchatroomWebRootWEB-INFclassescxdaoUserDao.class
............此处省略49个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)