package com.dwr.sendmessage;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import org.directwebremoting.Container;
import org.directwebremoting.ServerContextFactory;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.event.ScriptSessionEvent;
import org.directwebremoting.event.ScriptSessionListener;
import org.directwebremoting.extend.ScriptSessionManager;
import org.directwebremoting.servlet.DwrServlet;
public class DwrScriptSessionManagerUtil extends DwrServlet{
private static final long serialVersionUID = -7504612622407420071L;
public void init()throws ServletException {
Container container = ServerContextFactory.get().getContainer();
ScriptSessionManager manager = container.getBean(ScriptSessionManager.class);
ScriptSessionListener listener = new ScriptSessionListener() {
public void sessionCreated(ScriptSessionEvent ev) {
HttpSession session = WebContextFactory.get().getSession();
String userId =((User) session.getAttribute("userinfo")).getHumanid()+"";
System.out.println("a ScriptSession is created!"+"用户id="+userId);
ev.getSession().setAttribute("userId", userId);
}
public void sessionDestroyed(ScriptSessionEvent ev) {
System.out.println("a ScriptSession is distroyed");
}
};
manager.addScriptSessionListener(listener);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
dwr3实现根据用户id精准推动实例
共33个文件
class:8个
java:5个
jsp:3个
需积分: 10 10 下载量 85 浏览量
2017-08-09
08:52:49
上传
评论 2
收藏 1.18MB RAR 举报
温馨提示
dwr3实现服务器根据用户id向前端用户精准推送的实例,直接解压可运行,实例内部注解清晰,初学者可也看懂。访问http://localhost:8080/dwr/登录,访问http://localhost:8080/dwr/MyJsp.jsp进行推送。 放到myeclipse里面可直接运行服务器为tomcat
资源推荐
资源详情
资源评论
收起资源包目录
dwr3实现根据用户id精准推送消息.rar (33个子文件)
dwr
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.wst.common.component 447B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 395B
src
com
test
servlet
LoginAction.java 1KB
dwr
sendmessage
DwrScriptSessionManagerUtil.java 2KB
User.java 402B
MessagePush.java 721B
Test.java 1KB
.project 2KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 3KB
dwr.xml 863B
classes
com
test
servlet
LoginAction.class 2KB
dwr
sendmessage
Test.class 852B
User.class 735B
DwrScriptSessionManagerUtil.class 1KB
MessagePush.class 1KB
DwrScriptSessionManagerUtil$1.class 2KB
Test$1.class 1022B
Test$2.class 2KB
lib
commons-logging-1.1.1.jar 59KB
dwr.jar 1.13MB
dwr
engine.js 45KB
util.js 45KB
js
jquery-1.5.1.js 212KB
login.jsp 713B
index.jsp 2KB
MyJsp.jsp 1KB
.mymetadata 282B
.classpath 679B
.myeclipse
共 33 条
- 1
资源评论
执草书云
- 粉丝: 15
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功