Solved

automatic refresh of a jsp page

Posted on 2002-06-03
4
646 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to access elements of included jsp  from parent jsp's save button 9 22
Display current date,month,and year to JTextField 3 53
JSP Popup page 2 115
String format issue 13 91
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 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