• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

refresh jsp page

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing a demo chat application.
I am unable to refresh my application when a new message is posted.
How do we do this in jsp? I mean how do we refresh/reload the jsp page?
In servlets, there is response.setHeader for refreshing, are we supposed to
use the same.
Also, I went thru some other code. The author has used java script for doing this. I have pasted it below. I am now able to get that.
------------------javascript code-----------------------------
<!--
function reload()
{
window.location.reload();
}

setInterval('reload()', <%=refreshAfter%> ;

function winopen(path)
{
chatterinfo = window.open(path,"chatterwin","scrollbars=no,resizable=yes, width=400, height=300, location=no, toolbar=no, status=no");
chatterinfo.focus();
}
//-->
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Google on either meta-refresh or setTimeout. Both of these are handled on the client.

There is nothing specific to either JSPs or Servlets that has to do with refreshing a client's browser.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several ways for a browser to be refreshed:

Put this in the head section of the html

600 would be the number of seconds to wait, so you would probably put about
5 seconds.

or use a header:

Refresh: 600;/index.html or
Refresh: 600;

Again, 600 being the number of seconds to wait, Refresh header is non-standard but most browsers will recognize it

And of course you can use javascript.

Hope this helped
[ February 04, 2005: Message edited by: Kerry Wilson ]
 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all, I am able to do it.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic