File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes refresh (update) JSP webpage when JMS notification is received Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "refresh (update) JSP webpage when JMS notification is received" Watch "refresh (update) JSP webpage when JMS notification is received" New topic
Author

refresh (update) JSP webpage when JMS notification is received

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
After a notification from JMS is received, how to refresh (update) a JSP webpage?
Please post any tutorial or website or idea.
This is for FF, Chrome, IE on windows Vista & 7 and spring framework.
Thanks.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

What JSP page? How would you even know that a JSP is loaded, let alone refresh it?

You'll have to provide a lot more details.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
Bear Bibeault wrote:What JSP page? How would you even know that a JSP is loaded, let alone refresh it?

You'll have to provide a lot more details.



My web browser display the JSP web page (http://127.0.0.1:8080/myapp/alarm.htm) correctly so the JSP is loaded properly.
After the JMS notification is received, how to make my java program to get data from db and display it on a JSP web page?
Currently I have to click the "Refresh" button on the JSP web page to refresh it.
My java programs are as follows:

This message was edited 4 times. Last update was at by albert kao

Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

You can't automatically refresh anything from the server. Once the HTML generated from the JSP is sent to the browser, it's a done deal. When your notification comes in, the user could be looking at YouTube videos or pictures of kittens for all you know.

You can't really do anything until a new request comes in from the browser.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
Bear Bibeault wrote:You can't automatically refresh anything from the server. Once the HTML generated from the JSP is sent to the browser, it's a done deal. When your notification comes in, the user could be looking at YouTube videos or pictures of kittens for all you know.

You can't really do anything until a new request comes in from the browser.


Can the web page refresh call be made inside the JMS notification receiver?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Again, what web page? How would even know what client to update? There's no context at all so how would you know anything about anyone who has ever visited your site?

So the answer is no.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 639
The web page could use a timer of it's own, and continually check with the server to see if there is new information to display, couldn't it? I think this could be done with a simple timer or with a toolkit like Ajax.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
Bear Bibeault wrote:Again, what web page? How would even know what client to update? There's no context at all so how would you know anything about anyone who has ever visited your site?

So the answer is no.


You are right.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2161

Mark E Hansen wrote:The web page could use a timer of it's own, and continually check with the server to see if there is new information to display, couldn't it? I think this could be done with a simple timer or with a toolkit like Ajax.
or the brutal html META REFRESH tag.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
albert kao wrote:
Bear Bibeault wrote:Again, what web page? How would even know what client to update? There's no context at all so how would you know anything about anyone who has ever visited your site?

So the answer is no.


Is there any sample program or tutorial to check a mysql server and then update the JSP web page?

This message was edited 2 times. Last update was at by albert kao

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 12871

Was that a followup question? Because it's the same question as the original question, only you were hoping for some other technology to provide a magical way to do something which can't be done. And the answer to it, unsurprisingly, is "No".
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
Paul Clapham wrote:Was that a followup question? Because it's the same question as the original question, only you were hoping for some other technology to provide a magical way to do something which can't be done. And the answer to it, unsurprisingly, is "No".


Is it possible to use a javascript to refresh the jsp web page when some data is written to the database?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Sort of. You could use a timer to fire off an Ajax request periodically to check for updates.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
Bear Bibeault wrote:Sort of. You could use a timer to fire off an Ajax request periodically to check for updates.


I like to do this:
Refresh JSP web page when a jms message is received or the Apache DB database is changed.
How to do that?
Is there any Ajax sample code to do that?

This message was edited 1 time. Last update was at by albert kao

Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Any Ajax tutorial should let you know what you need to do. If you have Ajax questions, I suggest opening a new topic in the HTML forum to ask them.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 12871

albert kao wrote:
Refresh JSP web page when a jms message is received or the Apache DB database is changed.
How to do that?
Is there any Ajax sample code to do that?


Of course not. Javascript code in your browser isn't going to receive a JMS message, nor is it going to poll the database to see what has changed. But as already pointed out numerous times, you should forget about doing that. Just set up something to refresh the data periodically. When the data changes, you will get different data. If the data doesn't change, you will get the same data.

Setting up an Ajax timer to refresh data on a regular basis is quite simple. As Bear says, you should find that in plenty of tutorials. Just don't get distracted by your idea of only refreshing when the data changes.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 204
When there is little data, the automatic webpage refresh is ok.
However, when there is little data, the automatic webpage refresh make the webpage blink unpleasantly.
 
 
subject: refresh (update) JSP webpage when JMS notification is received
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com