Solved

display from HTML file is not getting refreshed

Posted on 2006-06-29
6
210 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

18 Experts available now in Live!

Get 1:1 Help Now