aspose file tools*
The moose likes Servlets and the fly likes make servlet continually refresh page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "make servlet continually refresh page" Watch "make servlet continually refresh page" New topic
Author

make servlet continually refresh page

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
hello, i've written a servlet that sends a certain number of messages. but, in the servlet response, i want it to be able to write a message to the screen each time a message is sent. So my question is, how do I automatically reload a page with a new value for a servlet. Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Put a meta refresh tag on the page

Example: For a 15 second refresh..


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
response.setHeader("refresh","15;URL=myServlet");

will also work


Sarath Mohan
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Alternate approach if only a small amount of data on the page needs to be updated would be to use JavaScript to make the request to your servlet and update the contents. This involves a LOT more work.
Bill


Java Resources at www.wbrogden.com
igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
Thanks for the help. it works
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
For true push from server to browser you can implement an applet that opens a ServerSocket and registers the IP & port with the app server. We use this to push messages to selected subsets of users, eg everyone in some site or some product support group. It's fairly tricky, but lets the server control who gets what with no polling from the browser.
[ March 29, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: make servlet continually refresh page
 
Similar Threads
calling javascript function
Problem with displaying image using jsp
Re: Servlet Redirect with time delay
How to give alert message in servlet and redirected it to jsp page.
How can i use message window in servlet