File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to have a page CONTINUE to check Database Record? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to have a page CONTINUE to check Database Record?" Watch "How to have a page CONTINUE to check Database Record?" New topic
Author

How to have a page CONTINUE to check Database Record?

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hello,
How to have a page CONTINUE to check Database Record? For example, there's a page which itself will periodically check the database, if there's any new data the page will Popup a new page with those data. My question is how can the page keep checking the database?
One of the solution(not good) is that there's a hidden frame with a hidden Servlet, it will refresh every x secs and connect database for every refresh, it seems not a good solution. Please suggest some idea. Thank you.
Ken


Thanks everyone who helped me
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
You are going to have to have either a hidden Applet (not Servlet) or a Javascript operation doing the checking. As you say, checking the database every few seconds is expensive - what about the process that may change the database - do you have any control over it? Could it signal the fact that a change has been made somehow?
Bill


Java Resources at www.wbrogden.com
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
>You are going to have to have either a hidden >Applet (not Servlet) or a Javascript operation
Hi,Applet is ok, but somepeople telling me that Applet can't control remote host(security reason),if u know, do u have any sample code for a applet to connect a db fequently? For Javascript operation, I think you mean this is a javascript keeping refresh the Servlet while the Servlet do the db connection and checking?
>the process that may change the database - do you >have any control over it?
Talking about the process, I may have a mobile agent which doing its job under the server or dispatched itself to other server and do query, finally after he finished querying, it will come back to our server to update the database.
Thanks
Chris May
Greenhorn

Joined: Mar 31, 2002
Posts: 15
The simplest way to do this is to use the META-REFRESH html tag. This will reload a page every x seconds. This is pretty hard on your servers, but easy on the development
<META HTTP-EQUIV="Refresh" CONTENT="30; URL=http://www.yoursite.com/some/place/">
The most modern way IMHO would be to use RTML. http://www.caplin.com/browser/rtml.html


Never wrote a book. Never taught a class. Just write code. Quick and dirty. Works for me.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi May, I don't want to have a hidden frame in my menu, so if Applet can do that, I can embed the hidden applet in the user menu, which keep checking the database and if db is updated, it will popup a new page (servlet page), but I don't know how to make it or if it's possible.
For RTML, have any sample code area? thanks for your suggestion
Chris May
Greenhorn

Joined: Mar 31, 2002
Posts: 15
Hi, there is no need for any frames. Just put the meta-refresh tag in the head section of the document you want to refresh with a reflexive (self-referencing) URL. The RTML stuff is cool, I've seen it in action, and have some whitepapers on it at work, but I haven't done any of it myself. I'm pretty sure it requires a proprietary server. Check the URL I linked above, and if it's all the same to you, I prefer to be informally called by my first name "Chris", not my last name "May" Good luck.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
How about a JMS solution?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Chris, the reason for me to have hidden frame for refreshing is that once the user login, it will have a static menu on the left and the main screen on the right displaying information for the users, those refresh html tag can't be embedded inside those frames as those frames will be refreshed all the time.
Thomas, what is JMS solution?
Thx
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Java Messaging Services. You set up a JMS server and post database updates to a topic on the server. Then applets/applications can subscribe to that topic and get automatically notified whenever anything is added to the topic.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
It sounds interesting! Could you provide me some tutorial about implementing applet with that server? And what ver jdk it uses? (As a matter of fact, my project need to use tomcat,JRUN,2 Aglet Server and MySQL together, all these combinations need use different ver of jdk.. at least 3 ver., the setting really make me headache.. :=o )
Chris May
Greenhorn

Joined: Mar 31, 2002
Posts: 15

Chris, the reason for me to have hidden frame for refreshing is that once the user login, it will have a static menu on the left and the main screen on the right displaying information for the users, those refresh html tag can't be embedded inside those frames as those frames will be refreshed all the time.
Perhaps I don't understand Gaelic, but I still see no reason that you can't do a meta-refresh in the document to the right, but hey, it seems that you're hell bent on turning something very simple into something complex, so by all means, have at it. I'm sure it's just a matter of semantics, but if the frame on the right is going to be refreshed "all the time" why do you bother trying to refresh the data programmatically?
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
I should correct the sentence like this: those refresh html tag can't be embedded inside those frames, if so, those frames will be refreshed all the time.
Like the following image:

Left is menu and right is working place, so it's not reasonable to insert a reload tag at both frames. The only solution is to insert a hidden frame as pic shown, but it's quite 'dirty' if user find that there's frame keeping refreshing..
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Thomas Paul:
.....Then applets/applications can subscribe to that topic and get automatically notified whenever ......


in which version of java that a applet can be used as a JMS Client???
:roll:
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi,thomas,
can u give me some hint on how to use JMS or download it?(and use with applet,bacuase my deadline is coming soon,thanks very much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to have a page CONTINUE to check Database Record?
 
Similar Threads
automatic refresh of a jsp page
Displaying Data
REFRESH A JSP PAGE
problem with page refresh
Refresh jsp page