Solved

display from HTML file is not getting refreshed

Posted on 2006-06-29
6
217 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Read  the original post  on Monitis Blog. Hi.  My name is Erik Dietrich, and this is the first time I’ve posted on the Monitis blog.  By way of introduction, I thought it would make sense to talk about my initial experience with Monitis.   Befo…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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