• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

make servlet continually refresh page

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put a meta refresh tag on the page

Example: For a 15 second refresh..
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response.setHeader("refresh","15;URL=myServlet");

will also work
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. it works
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic