• Post Reply Bookmark Topic Watch Topic
  • New Topic

refresh jsp page  RSS feed

 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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();
}
//-->
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks all, I am able to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!