Solved

display from HTML file is not getting refreshed

Posted on 2006-06-29
6
212 Views
Last Modified: 2010-04-01
Here is the scenario....

I prepare a servlet whein the doGet() I make the presentation GUI. Comes out very nice.

I have a push button and at the click of the push button goes to doPost() where I UPDATE A .HTML FILE DYNAMICALLY.
doPost() calls toGet() to reload the new contents. Then onLoad() of the next round I am displaying the contents of the
html file (with updated values) on a messageDialog window.

The problem I have is that although the HTML file is physically getting updated (I can see this when I list the contents of the
file by hand) at the click of the button, onLoad() (in the second round) does not refersh the file in the container. seems like
that it simply shows the file that was loaded into the container in the first instance.

How to instruct to reload HTMLthe file into the container every next round?.

I tried pressing "refresh" button on the browser, but no good.

-prain
0
Comment
Question by:prain
  • 2
  • 2
  • 2
6 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 17014990
I don't know if I can help because I am confused by your question. If you restate, then maybe someone will have a solution.  
>I UPDATE A .HTML FILE DYNAMICALLY.  
Are you editing a file on the server ?  Or are you talking about the response output of the servlet ?  Is this the GUI with the push button ?  
>calls toGet() to reload the new contents.    
Reload into what ? The browser ?  The html.file ?
>onLoad()  
Where is this method ? What calls it ?  Is it in the browser(DHTML) ? Is in the servlet ?
>does not refersh the file in the container.  
What container are you talking about ? The servlet container ?
Please explain in more detail and show us some code.
0
 

Author Comment

by:prain
ID: 17017278
rrz. Here is the short implementation of doGet() and doPost().

public void doGet (HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException
{

  In here, if the file was updated, I show the contents of message.html onLoad.
   
  if (fileUpdated)
  {
    out.println("<BODY onLoad=\"showMessageDialog('" + messageFilePath + "')\")>");

   ***Note that messageFilePath is the path to the message.html file. It is really sitting in
   the webapps directory.
  }
  else
  {
    out.println("<body>");
  }
}

public void doPost (HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException
{
 1.  Here I make a call to a Java class to write (edit) message.html file based on some requirements.
     The file (message.html) will have a new face or may not even have any change depending on
     the requirements. Notifier that a new messages was written is byt setting a flag (see (2) below) .  

2. Then I set a flag that the file was updated. (say fileUpdated = true)
 
3. Then I call doGet();
}

Now what happens here is that when the push button is clicked first time, it comes to doPost(), updates the
message.html file. Lets say that the message.html was updated to "Hello World". So I see this corrrect onLoad in doGet().
with the gui comes up corret with the message box. Now I click the push button again. Lets say the message.html
was now (2nd Time) updated to "Hello World, This is a crazy world". Then I see the old message "Hello World" poping up again.
But when I see the message.html file physically, I see it has changed to the correct message "Hello World, This is a crazy world".

That file, message.html was not RELOADED second round. So this continues for any next cycle. Message never gets updated
and the first message "Hello World"  is shown always next rounds.
0
 
LVL 27

Expert Comment

by:rrz
ID: 17018486
I am still not sure what is gonig on here. My only guess is that is a browser cache problem.  Look at  
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21442362.html   
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q234067
To test to see if that is the problem, you could try adding the meta tags to message.html. For example  

<HTML><HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD><BODY>
testing
</BODY>
</HTML>

Maybe someone else has some other ideas.

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 75 total points
ID: 17029472

Change this line to

if (fileUpdated)
  {
Date d = new Date();
    out.println("<BODY onLoad=\"showMessageDialog('" + messageFilePath +"?"+ d"')\")>");

& try
0
 

Author Comment

by:prain
ID: 17030427
kuldeep,
Thanks so much. That simply works. So what's the inside trick here now?. Does it mean that the file is reloaded based on the
time tag of the file?.

prain
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 17031967
:-)
Its very common trick to fool the browser/proxy servers etc... what happens is that browsers cache the pages for a quick retrival ( for performance reasons)..
now if your URL is kept same, then the browser will not go to the server to fetch the page all over again but will display it from its own cache...
appending a time stamp to it changes the URL every time its accessed...:-) ( & hence browser is forced to go the server to read the file again...)..

I hope this gives you a explanation of my solution.....
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
immutable object concept 5 119
JSONSerializer.toJSON in JSP generating error 8 72
instanceof  operator in java 26 91
Why my table column Id is not passed to java object? 4 38
Employees depend heavily on their PCs, and new threats like ransomware make it even more critical to protect their important data.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

774 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