refresh JSP webpage when jms message is received or Apache DBdatabase is changed

A

albert kao

The goal is to refresh a JSP web page when a jms message is received
or the Apache DB database is changed.
How to do that with javascript or java?
Is there any sample code?
 
E

Erwin Moller

albert kao schreef:
The goal is to refresh a JSP web page when a jms message is received
or the Apache DB database is changed.
How to do that with javascript or java?
Is there any sample code?


Hi,

Sounds like you should poll the server from time to time from the client.
You could use XMLHttpRequest to do this without a pagereload.

Start reading here for a quick introduction:
http://www.w3schools.com/ajax/

On the server you could create a file that holds a timestamp (for example).
Pull that file from your client every 60 secs or so. If it is changed,
refresh the page and make sure you store the new value of the timestamp
(via cookie or serverside scripting, whatever).

Also, when you feel there is some reason for your clients to refresh
(message arrived, db updated), simply update that file on the server
with the new timestamp in it.

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
A

albert kao

albert kao schreef:


Hi,

Sounds like you should poll the server from time to time from the client.
You could use XMLHttpRequest to do this without a pagereload.

Start reading here for a quick introduction:http://www.w3schools.com/ajax/

On the server you could create a file that holds a timestamp (for example).
Pull that file from your client every 60 secs or so. If it is changed,
refresh the page and make sure you store the new value of the timestamp
(via cookie or serverside scripting, whatever).

Also, when you feel there is some reason for your clients to refresh
(message arrived, db updated), simply update that file on the server
with the new timestamp in it.

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare

Should the new value of the timestamp be stored at the client (not
server)?
i.e. On the server you could create a file that holds a timestamp (for
example).
Pull that file from your client every 60 secs or so. If it is changed,
refresh the page and make sure you store the new value of the
timestamp at the client.

Also, when you feel there is some reason for your clients to refresh
(message arrived, db updated), simply update that file on the server
with the new timestamp in it.
 
E

Erwin Moller

albert kao schreef:
Should the new value of the timestamp be stored at the client (not
server)?

Yes sure.
The client should compare the timestamp found on the server with its own
timestamp to decide if it needs a pagerefresh.
You could use a cookie for this (or some variable parsed into JavaScript
by the script that produces that page. Whatever is the easiest for you)

i.e. On the server you could create a file that holds a timestamp (for
example).
Pull that file from your client every 60 secs or so. If it is changed,
refresh the page and make sure you store the new value of the
timestamp at the client.

Also, when you feel there is some reason for your clients to refresh
(message arrived, db updated), simply update that file on the server
with the new timestamp in it.

Yes, the above sounds very familiar. ;-)

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top