Solved

automatic refresh of a jsp page

Posted on 2002-06-03
4
644 Views
Last Modified: 2009-12-16
hi all,
I have a problem regarding refreshing a jsp page. The first time I call the jsp file, the data from the database is displayed correctly. But when I update the DB, and call the jsp page, the data displayed in the browser is not updated. I still have to press "ctrl-r" to update the display. How would I update the display in the browser without using "ctrl-r"?

thanks.
0
Comment
Question by:eaglesview
4 Comments
 
LVL 4

Accepted Solution

by:
pellep earned 200 total points
ID: 7050899
put these HTML statements on top of your page (ie inside the <head> section)

<HEAD>
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache">
</HEAD>
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7051220
Actually, the best thing that works in IE and Netscape is to have the following:
<%
response.addHeader("Pragma" , "No-cache") ;
response.addHeader("Cache-Control, "no-cache") ;
response.addDateHeader("Expires", 0);  
%>

BOTH in the head of the of page and bottom of the page (I read this in a message board and it seems
to work for me)

<html>
<head>
<%
// this prevents caching in NS and IE
response.addHeader("Pragma" , "No-cache") ;
response.addHeader("Cache-Control, "no-cache") ;
response.addDateHeader("Expires", 0);  
%>
<!-- this will refresh the page every 5 seconds -->
<META HTTP-EQUIV=Refresh CONTENT="5; URL=currentJSP.jsp"/>
</head>
<body>

....

</body>
<%
// this helps prevent caching in IE
response.addHeader("Pragma" , "No-cache") ;
response.addHeader("Cache-Control, "no-cache") ;
response.addDateHeader("Expires", 0);  
%>
</html>

Also what you can do is add a random number at the end of the URL when you do the meta refresh.

HTH,
CJ
0
 
LVL 1

Expert Comment

by:raid999
ID: 7052255
you can also set a timer in the JSP page and then use response.redirect(URL);
0
 

Author Comment

by:eaglesview
ID: 7052674
thanks.. it solved my problem.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now