Update a page on receiving a message from the server

S

sconeek

hi all,
i am trying to put some code within my js such that, when the server
"sends it a message" it refreshes the page. now i have the refresh part
of things. the place where i am stuck is, how can my server (tomcat, am
using a java web app) send a very small piece of info to the js which
when it receives it, refreshes the page. any pointers.
thanks to all.
 
E

Erwin Moller

hi all,
i am trying to put some code within my js such that, when the server
"sends it a message" it refreshes the page. now i have the refresh part
of things. the place where i am stuck is, how can my server (tomcat, am
using a java web app) send a very small piece of info to the js which
when it receives it, refreshes the page. any pointers.
thanks to all.

Hi,

What you describe is often called 'server-push' I think.
I don't think you can do this easily.
Webservers want to terminate their response.
HTTP is not like a bidirectional socket, that waits for some action to
happen from either side.

It makes more sense to make the client pull. (Named polling)
So from your JS, you check every minute or so if the page needs refreshing.

This can be implemented with a hidden frame, or via AJAX-like approach.

If you want your client (the webbrowser) to keep in touch with the server
without polling, you'll have to try to implement an applet that opens a
socket to the server or something like that, but that is a lot more work
(and less reliable) than letting JS poll every minute.

Regards,
Erwin Moller
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top