Solved

Refreshing JSP codes to check for data updates without refreshing the entire browser(eg. does not affect a user reading a article while constantly refreshing in the backgrd)

Posted on 2003-11-13
5
483 Views
Last Modified: 2010-04-06
Hi.. I have a urgent question. Basically I have this site written in JSP that allows one computer to send a "instant message" to another computer(both at a specific webpage of my site). The message sent is first stored in a vector/file/db and then retrieved when computer B(reciever) refreshes the page and the codes check that boolean newMsg=true; and displays the message in a Alert box.

My problem is, the reciever has to manually click refresh to check for any new messages. What I need is for the "refresh" to somehow.. run (in the background?) without disturbing the reciever(perhaps reading a article). And when a new message is detected, the Alert box will pop up.

Hope I make this clear enough. Please help! Thanks!
0
Comment
Question by:lewin85_sg
5 Comments
 
LVL 1

Accepted Solution

by:
linc0ln earned 500 total points
ID: 9741057
I'm not sure if you can handle that completely on the server side.  I believe what you want to do is create a hidden frame or possibly an iframe, I'll call it the lookup frame.  

In the lookup frame you would run a separate jsp that does the db lookup and if new messages are found, communicates the results to the viewing frame via javascript.  The lookup frame could use a meta-refresh to periodically reload to check for new messages.

Hope this helps.

Linc
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9743432
linc0ln is correct, you can't "push" from a server to a browser.  The browser is in control of the communications and the server simply responds.

<META HTTP-EQUIV=Refresh CONTENT="10; URL=http://url.to.servlet">

The meta-refresh should be nice and easy to implement (not all browsers support it, but I don't know which ones).  You could do it with an applet, but that's considerably more work ;-)
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9745907
I dont'think there are any graphical browsers that produced in the last 6-7 years that don't support meta refresh tags. That shouldn't be an issue.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9746535
;-)  Thanx Zontar.
0
 
LVL 1

Author Comment

by:lewin85_sg
ID: 9747070
Thanks guys :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now