• 大小: 2.6MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-29
  • 语言: Java
  • 标签: jsp  课程设计  

资源简介

jsp聊天室课程设计

资源截图

代码片段和文件信息

package message;

import java.io.IOException;
import java.io.PrintWriter;
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 message.bean.User;
import message.dao.Dao;
import org.apache.log4j.*;
import org.apache.log4j.xml.DOMConfigurator;
import org.json.simple.*;

/**
 * Servlet implementation class ajaxNewMessage
 */
public class ajaxNewMessage extends HttpServlet {
private static final long serialVersionUID = 1L;
private Logger logger = Logger.getLogger(this.getClass());

/**
 * @see HttpServlet#HttpServlet()
 */
public ajaxNewMessage() {
super();
// TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request HttpServletResponse
 *      response)
 */
protected void doGet(HttpServletRequest request
HttpServletResponse response) throws ServletException IOException {
// TODO Auto-generated method stub
DOMConfigurator.configure(getServletContext().getRealPath(“/“)
+ “log4j.xml“);
response.setContentType(“text/html“);
response.setCharacterEncoding(“UTF-8“);
PrintWriter out = response.getWriter();
Dao dao = new Dao();
String username;
if (request.getSession().getAttribute(“username“) == null
|| request.getSession().getAttribute(“username“).toString()
.length() == 0) {
out.print(“ript>window.location.href=‘login.jsp‘ript>“);
out.flush();
return;
} else {
username = request.getSession().getAttribute(“username“).toString();
}
ServletContext application = this.getServletContext();
@SuppressWarnings(“unchecked“)
List userlist=(List)application.getAttribute(“USERLIST2“);
User user=new User();
user.setUsername(username);
user.setLastAccessTime(System.currentTimeMillis());
for(User u:userlist){
if(u.getUsername().endsWith(username)){
userlist.remove(u);
userlist.add(user);
break;
}
}
for(int i=0;i if(System.currentTimeMillis()-userlist.get(i).getLastAccessTime()>1000*60){
userlist.remove(i);
}
}
application.setAttribute(“USERLIST2“userlist);
List msg;
if (request.getSession().getAttribute(“maxId“) == null
|| Integer.parseInt(request.getSession().getAttribute(“maxId“)
.toString()) == 0) {
int MaxId = dao.GetMaxId();
msg = dao.GetMessagesByMaxId(MaxId);
request.getSession().setAttribute(“maxId“ MaxId);
} else {
int maxId = Integer.parseInt(request.getSession()
.getAttribute(“maxId“).toString());
msg = dao.GetMessagesByMaxId(maxId);
request.getSession().setAttribute(“maxId“ maxId);
}
for (message.domain.ShowMessage m : msg) {
if (!m.username.equals(username)) {
String outText = “

  •  属性            大小     日期    时间   名称
    ----------- ---------  ---------- -----  ----

         文件        486  2011-04-11 22:13  AjaxChat\.classpath

         文件       1257  2011-01-20 19:53  AjaxChat\.project

         文件        483  2011-04-11 22:13  AjaxChat\.settings\.jsdtscope

         文件         88  2011-01-17 14:12  AjaxChat\.settings\org.eclipse.core.resources.prefs

         文件         83  2011-01-17 14:12  AjaxChat\.settings\org.eclipse.core.runtime.prefs

         文件        330  2010-12-31 15:18  AjaxChat\.settings\org.eclipse.jdt.core.prefs

         文件        396  2011-04-11 22:13  AjaxChat\.settings\org.eclipse.wst.common.component

         文件        229  2011-04-11 22:13  AjaxChat\.settings\org.eclipse.wst.common.project.facet.core.xml

         文件         49  2011-01-17 19:08  AjaxChat\.settings\org.eclipse.wst.jsdt.ui.superType.container

         文件          6  2011-01-17 19:08  AjaxChat\.settings\org.eclipse.wst.jsdt.ui.superType.name

         文件        851  2011-04-11 22:13  AjaxChat\build\classes\log4j.xml

         文件       4802  2011-04-12 21:48  AjaxChat\build\classes\message\ajaxNewMessage.class

         文件       2806  2011-04-09 21:22  AjaxChat\build\classes\message\ajaxPostNewMessage.class

         文件       1368  2011-04-09 21:22  AjaxChat\build\classes\message\bean\Message.class

         文件       1141  2011-04-11 23:18  AjaxChat\build\classes\message\bean\User.class

         文件       5455  2011-04-09 21:22  AjaxChat\build\classes\message\dao\Dao.class

         文件       1196  2011-04-09 21:22  AjaxChat\build\classes\message\domain\ShowMessage.class

         文件       3041  2011-04-11 23:48  AjaxChat\build\classes\message\GetOnlineUser.class

         文件       1080  2011-04-11 22:13  AjaxChat\build\classes\message\ibatis\Message.xml

         文件        962  2011-04-13 19:34  AjaxChat\build\classes\message\ibatis\sqlMapConfig.xml

         文件        727  2011-04-11 22:13  AjaxChat\build\classes\message\ibatis\User.xml

         文件       3720  2011-04-12 21:36  AjaxChat\build\classes\message\Login.class

         文件       2676  2011-04-11 23:39  AjaxChat\build\classes\message\Logout.class

         文件       1938  2011-04-09 21:22  AjaxChat\build\classes\message\RegUser.class

         文件        851  2011-04-11 22:13  AjaxChat\src\log4j.xml

         文件       3779  2011-04-12 21:48  AjaxChat\src\message\ajaxNewMessage.java

         文件       1958  2011-02-15 22:59  AjaxChat\src\message\ajaxPostNewMessage.java

         文件        316  2011-01-17 15:12  AjaxChat\src\message\bean\.svn\all-wcprops

         文件        589  2011-01-17 15:12  AjaxChat\src\message\bean\.svn\entries

         文件         39  2011-01-17 15:11  AjaxChat\src\message\bean\.svn\prop-base\Message.java.svn-base

    ............此处省略305个文件信息

    评论

    共有 条评论