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
484 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Owl Carousel 6 173
Clean URL from GET variables 2 93
Facebook React and SyntheticEvents 6 49
How to write an English digest paper 6 24
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 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