message drive bean 里收到消息后怎样刷新一个页面 急 在线等候。。。。 一个用户登陆后mdb收到消息然后判断监控页面是否打开如果是就刷新他请问怎么实现 不判断页面是否打开也行不懂什么意思! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用户登录的时候登录模块向监控模块发送消息 后者收到消息后去主动刷新一个页面比如monitor.jsp贴上发送和接受的代码这个是父类提供一些发送端和接收端公共的属性以继承package com.lbsman.jms;import java.util.*;import javax.jms.*;import javax.naming.*;import com.lbsman.common.PropertyFile;public class JMSBase { private String QCFName; private String QueueName; protected Context ctx; protected QueueConnectionFactory QCF; protected QueueConnection QC; protected Queue queue; protected QueueSession QSession; public JMSBase() { ctx = null; QCF = null; QC = null; queue = null; QSession = null; PropertyFile pFile = new PropertyFile(); pFile.setPropFile("c:/webinfo/web.properties"); QCFName = pFile.getProp("QFCName"); QueueName = pFile.getProp("QueueName"); } protected Context getInitialContext() throws NamingException { if (ctx == null) { try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ctx = new InitialContext(p); } catch (NamingException ne) { System.err.println("** Unable to connect to the server"); ne.printStackTrace(); throw ne; } } return ctx; } protected void prepare() throws NamingException,JMSException { ctx = getInitialContext(); QCF = (QueueConnectionFactory)ctx.lookup(QCFName); queue = (Queue)ctx.lookup(QueueName); ctx.close(); QC = QCF.createQueueConnection(); QSession = QC.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); }}发送部分:package com.lbsman.jms;import javax.jms.*;public class LBSQSender extends JMSBase { private QueueSender QSender; private TextMessage TMSG; private String MsgContent; public LBSQSender() { super(); QSender = null; TMSG = null; MsgContent = ""; } public String getMsg() { return MsgContent; } public void send(String msgCon) throws JMSException { MsgContent = msgCon; QSender = QSession.createSender(queue); TMSG = QSession.createTextMessage(MsgContent); QSender.send(TMSG); } public static void main(String[] args) { LBSQSender Sender = new LBSQSender(); try { Sender.prepare(); Sender.send("hello"); } catch (Exception e) { e.printStackTrace(); } }}接收程序package com.lbsman.jms;import javax.jms.*;import javax.servlet.http.HttpServletResponse;import com.lbsman.database.Database;import com.lbsman.common.InputCheck;public class LBSQReceiver extends JMSBase implements MessageListener { private QueueReceiver QReceiver; private HttpServletResponse response; public LBSQReceiver(HttpServletResponse resp) { super(); QReceiver = null; response = resp; } public LBSQReceiver() { super(); QReceiver = null; response = null; } private void receive() throws JMSException { QReceiver = QSession.createReceiver(queue); QReceiver.setMessageListener(this); QC.start(); } public void onMessage(Message message) { String msgText = ""; String sqlStr = ""; int usrid = 0; InputCheck check = new InputCheck(); try { msgText = ( (TextMessage) message).getText(); System.out.println(msgText); } catch (JMSException e) { e.printStackTrace(); } if (check.isNum(msgText)) { try { usrid = Integer.parseInt(msgText); } catch (Exception e) { e.printStackTrace(); System.exit(0); } try{ response.sendRedirect("http://localhost:8080/"); } catch(Exception e){ e.printStackTrace(); } } } public static void main(String[] args) { LBSQReceiver Receiver = new LBSQReceiver(); try { Receiver.prepare(); Receiver.receive(); } catch (Exception e) { e.printStackTrace(); } }}LBSQReceiver接收到消息后在onMessage(Message message)怎么样去刷新一个指定的页面比如说刷新http://localhost/myjob/monitor.jsp http的连接是无状态的,文件传输完了连接就断开了,好像不行吧。可以用APPLET试试啊。 后者收到消息后可以改变你要记录的数据,然后将monitor.jsp设为定事刷新,不知道满不满足你的要求! 靠想来想去除了用applet没有别的办法一个javabean或者servlet的生存期有多长。我是指在javabean里的方法被调用后或者servlet的service方法别调用后他的实例就销毁了吗 wafer_w(流浪的风) 如过我定时刷页面那还用jms干什么 用的Myeclipse的web项目启动不了 问用struts 2.0 通过jsp向action传值的问题 正则表达式 校验 小弟初学webservice,请教一个简单的问题,本人一直解决不了,网上找了很久也没有解决的方法 恳请指教:如何捕获提交事务(TransactionInterceptor)时产生的异常 java连接SQL所出现的问题,跪求高手解决!!! 讨论,复杂流程的中订单的状态 !!!!同"高分求教"!!!!! 正在学习ejb, 想把雷霆bbs改成ejb版的。 大家有兴趣吗? 1000分悬赏 新手求救!!! J2EE 新手求助!!!!
这个是父类提供一些发送端和接收端公共的属性以继承
package com.lbsman.jms;import java.util.*;
import javax.jms.*;
import javax.naming.*;
import com.lbsman.common.PropertyFile;public class JMSBase {
private String QCFName;
private String QueueName;
protected Context ctx;
protected QueueConnectionFactory QCF;
protected QueueConnection QC;
protected Queue queue;
protected QueueSession QSession; public JMSBase() {
ctx = null;
QCF = null;
QC = null;
queue = null;
QSession = null;
PropertyFile pFile = new PropertyFile();
pFile.setPropFile("c:/webinfo/web.properties");
QCFName = pFile.getProp("QFCName");
QueueName = pFile.getProp("QueueName");
} protected Context getInitialContext() throws NamingException {
if (ctx == null) {
try {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ctx = new InitialContext(p);
}
catch (NamingException ne) {
System.err.println("** Unable to connect to the server");
ne.printStackTrace();
throw ne;
}
}
return ctx;
} protected void prepare() throws NamingException,JMSException {
ctx = getInitialContext();
QCF = (QueueConnectionFactory)ctx.lookup(QCFName);
queue = (Queue)ctx.lookup(QueueName);
ctx.close();
QC = QCF.createQueueConnection();
QSession = QC.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
}
}发送部分:
package com.lbsman.jms;import javax.jms.*;public class LBSQSender
extends JMSBase {
private QueueSender QSender;
private TextMessage TMSG;
private String MsgContent; public LBSQSender() {
super();
QSender = null;
TMSG = null;
MsgContent = "";
} public String getMsg() {
return MsgContent;
} public void send(String msgCon) throws JMSException {
MsgContent = msgCon;
QSender = QSession.createSender(queue);
TMSG = QSession.createTextMessage(MsgContent);
QSender.send(TMSG);
} public static void main(String[] args) {
LBSQSender Sender = new LBSQSender();
try {
Sender.prepare();
Sender.send("hello");
}
catch (Exception e) {
e.printStackTrace();
} }}
接收程序
package com.lbsman.jms;import javax.jms.*;
import javax.servlet.http.HttpServletResponse;
import com.lbsman.database.Database;
import com.lbsman.common.InputCheck;public class LBSQReceiver
extends JMSBase
implements MessageListener {
private QueueReceiver QReceiver;
private HttpServletResponse response; public LBSQReceiver(HttpServletResponse resp) {
super();
QReceiver = null;
response = resp;
}
public LBSQReceiver() {
super();
QReceiver = null;
response = null;
} private void receive() throws JMSException {
QReceiver = QSession.createReceiver(queue);
QReceiver.setMessageListener(this);
QC.start();
} public void onMessage(Message message) {
String msgText = "";
String sqlStr = "";
int usrid = 0;
InputCheck check = new InputCheck();
try {
msgText = ( (TextMessage) message).getText();
System.out.println(msgText);
}
catch (JMSException e) {
e.printStackTrace();
}
if (check.isNum(msgText)) {
try {
usrid = Integer.parseInt(msgText);
}
catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
try{
response.sendRedirect("http://localhost:8080/");
}
catch(Exception e){
e.printStackTrace();
}
}
} public static void main(String[] args) {
LBSQReceiver Receiver = new LBSQReceiver();
try {
Receiver.prepare();
Receiver.receive();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
LBSQReceiver接收到消息后在onMessage(Message message)
怎么样去刷新一个指定的页面比如说刷新http://localhost/myjob/monitor.jsp