Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

display from HTML file is not getting refreshed

Posted on 2006-06-29
6
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 28

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 28

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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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