Solved

display from HTML file is not getting refreshed

Posted on 2006-06-29
6
207 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
JspWriter.write() and JspWriter.print() 4 76
ajax auto save 15 93
Display the newly inserted values 3 72
nested if has else if 13 88
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

743 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

11 Experts available now in Live!

Get 1:1 Help Now