• Post Reply Bookmark Topic Watch Topic
  • New Topic

refresh (update) JSP webpage when JMS notification is received  RSS feed

 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2632
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Clapham
Sheriff
Posts: 22521
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of. You could use a timer to fire off an Ajax request periodically to check for updates.
 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 22521
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!