wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to continously run a background servlet!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to continously run a background servlet!!!" Watch "How to continously run a background servlet!!!" New topic

How to continously run a background servlet!!!

Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi EveryBody,
I am working on a intranet Messaging System which involves sending messages to valid users whose name and password is maintained in a database table.Now the whole scenario is something like this when the sender sends a message to a valid user he gets a form in which he types his username,his own name and the message, this calls a servlet which updates a database table and checks whether the user to whom he sends the message has currently logged in or not(This is accomplished when the user logs in he calls a servlet which sets a flag in a databse table which contains valid username, password and a flag,this flag is set to on).Once he checks that the user has logged in he stores this information in a flat file which resides on the server.This file contains the username to whom the mesage is send, and a flag stating whether a particular message is read on not.
Now I need to pop up a message to the sender everytime he recieves a new message.For this whenever the sender logs in his flag is set on on the databse table and then he has to "READ THIS FILE CONTINOUSLY , WHENEVER HE CHECKS ANY ENTRY OF HIS NAME IN THIS FILE,IT HAS TO PROMPT A MESSAGE SAYING U HAVE NEW MAIL"something what we get in a yahoo or any chat application.
Please suggest me best possible ways to achieve this, my limitation is I can't use an applet(otherwise life wd have been easier for me)
Thanking u all in advance.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
There are HTML tags that will continually refresh a page every so often. I'm not remembering it right off the top of my head now what the tag name is, but I know that this is true. Check an HTML 4.0 reference and look for it.
You just add that tag to the output of your servlet or JSP and it will re-request the page every so often. Your servlet or JSP will then simply include Javascript or a piece of HTML saying "Youv'e got mail" when it's present.
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695


I think that's it.
[This message has been edited by Mike Curwen (edited October 30, 2001).]
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
how best can i use client's pull i.e setHeader("refresh",5) in the response object or server's push i.e using a Multi-part response object .which would be ideal for the given scenario
I agree. Here's the link: http://aspose.com/file-tools
subject: How to continously run a background servlet!!!
Similar Threads
servlet 4b checking password in VideoLoginServlet
Servlet running continously and refreshing data!!
Entity Bean unavailable to me
Authnetication and getRemoteUser()
How to get session object by giving Session Id to kill another session in Websphere