Trying to read a textfile with AJAX and Caching

Hello all,
I have a simple jsp that utilizes ajax to read the contents of a text file<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*,java.io.*"%>
<%
    Date date = new Date();
    String dateString = date.toString();
%>
<html lang="en" dir="ltr">
  <head>
    <meta http-equiv="refresh" content="20" url="ajax.jsp?ms='<%=date.getTime()%>'">
    <META HTTP-EQUIV="EXPIRES" CONTENT="-1">
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Example</title>
<script type="text/javascript"><!--
var xmlObj = null;
function ajaxRead(file){
  //var xmlObj = null;
  if(window.XMLHttpRequest){
      xmlObj = new XMLHttpRequest();
  } else if(window.ActiveXObject){
      xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
      return;
  xmlObj.onreadystatechange = function(){
    if(xmlObj.readyState == 4){
       updateObj('ta', xmlObj.responseText);
    xmlObj.open ('GET', file, true);
    xmlObj.send ('');
  function updateObj(obj, data){
   document.getElementById(obj).firstChild.data = data;
   alert(window.getURL());
  //--></script>
  </head>
  <body onload="ajaxRead('logger/Jan26EventLog.txt'); this.style.display='none'; return false">
    <pre>
    <textarea rows="8" cols="26" id="ta" name="ta">
    </pre>
  </body>
</html>This works fine but the file that I am reading is a log file so it changes frequently. The problem I am having is that as the text file changes each subsequent ajax request to the file results in the original contents of the text file and not the new updated (appended) contents of the text file.
Even after many many ajax requests still the original contents. As you can see I have done all I can to prevent caching(that I know of). If I close the browser and relaunch I get the most current version of the text file.
I am using netbeans 5 and the built in version of tomcat. Is there a setting in the server.conf file that will prevent caching? Is there something in the code that is wrong?
I am at wits end with this problem so any advice is greatly appreciated.
TIA!

I have it partially figured out.
This is just temporary (afa the refresh goes), in the future I will use ajax to pull the data without a refresh.
The problem was here:
xmlObj.send (' ');//I had this
xmlObj.send (false);//I needed this.The problem I have now is:
I have an event handler that resides in
(project is called agi)
C:\Documents and Settings\gforte\agi\src\java\agi\EventHandler.java
which writes to the log file here:
C:\Documents and Settings\gforte\agi\web\logger\Jan26EventLog.txt
The code on my ajax call that sets the file to read is:
<body onload="ajaxRead('./logger/Jan26EventLog.txt')//calls the ajax function and sets the path to the fileThe page is actually reading the file here:
C:\Documents and Settings\gforte\agi\build\web\logger\Jan26EventLog.txt
which is not updated , or perhaps updated but not frequently enough.
So how do I :
1. read from the build directory path
2.write to a different location and read from that location
3. some other suggestion?
I tried to explicitly set the path to the desired file:
<body onload="ajaxRead('C:\Documents and Settings\gforte\agi\build\web\logger\Jan26EventLog.txt')
but ajax doesnt like this.
TIA!

Similar Messages

  • Trying to sync my iPod with iTunes and I am getting this message:"This computer is no longer authorized to play purchased items that are on the ipod"...  I have deauthorized and reauthorized the account and still getting the same error.

    Trying to sync my iPod with iTunes and I am getting this message:"This computer is no longer authorized to play purchased items that are on the ipod"...  I have deauthorized and reauthorized the account and still getting the same error.  I have read and followed the instructions in the support article TS1389.  I do NOT have an SC info folder at /Users/Shared/ directory to delete.
    I just installed Lion yesterday, and am running iTunes 10.4.   First attempt to sync since upgrade.
    Thanks
    Dan

    Yup,
    Me too...this is stupid, stupid, stupid. Just purchased my 200 (ish) mac and now I am told that my new Mac Book pro is not "authorized".
    Which if my 200 macs are authorized. Can someone please tell me???
    I "deauthorized" my old MBP and still told I cannot use my iPhone with iTunes.
    Interesting that my old $2500 MBP, my new $3000 MBP and my $500 iPhone all cannot work cuz of some pinhead's decision to use this assorization process.
    Yes I am very, very, very mad.

  • TS3682 im trying to restore my iphone with itunes and it gives me this error "We're sorry, we are unable to continue with your activation at this time."

    im trying to restore my iphone with itunes and it gives me this error "We're sorry, we are unable to continue with your activation at this time."

    This is usually a symptom that the phone was hacked/jailbroken. Was it?

  • I was trying to sync my iphone4 with itunes and my phone was pgraded to ios version, i now cannot make call on my iphone because my sim cannot be recognised again. what do i do plsssssss.

    i was trying to sync my iphone4 with itunes and my phone was upgraded to ios5 version, i now cannot make call on my iphone because my sim cannot be recognised again. what do i do plsssssss.

    As peter says, this is evidence that your phone was previously hacked and was re-locked by the upgrade.
    ONLY the carrier it is locked to can unlock it.  There is nothing else we can suggest.

  • Hi I just got a new macbook pro i7 processor and i am trying to send a email with  iPhoto and it comes back with The Email sever didn't recognise your username /password combination I'm with btyahoo  thats my I S P

    hi i just got a apple macbook pro on sat... it is the i7 processor 13inch.. the thing is i have been trying to send a picture with iphoto but it just comes back with the sever didn't recognise my Email/password combination

    Go to the Mac App Store main page and click on Support under Quick Links.
    (82704)

  • I was trying to pair my notebook with iphone3gs and i had problems with my internet connectivity,so the iphone gave an error message that should it ignore my pc, not thinking clearly i clicked ok.since then i couldnt pair my iphone with mypc via bluetooth

    Trying to pair my phone with my pc via bluetooth , had internet connection error .my iphone asked to forget about my pc and i clicked yes thinking i can redo the connection later but ever since, my iphone as refused to discover my pc .i have tried every thing i know but to no avail . can you pls help
    thanks

    Edge has very clear restrictions, one being that you must have 6 months of clean payment history which you don't. Either wait until April 14, or good luck at Sprint.
    I am unsure how it can be determined the payment mix up was the fault of CS, but regardless, the mix up was done. There can be any number of reasons why a payment could be missed without any fault on your part, however you are still the responsible party for the account and must live with the repercussions.

  • What is the difference between READ TABLE ITAB WITH KEY  and  TABLE KEY

    Hi Experts,
    what is the difference between
    READ TABLE <ITAB> WITH KEY <K1> = <C1>
                                                    <Kn> = <Cn> .
    and 
    READ TABLE <ITAB> WITH TABLE KEY <K1> = <C1>
                                                              <Kn> = <Cn> .
    Thanks
    Akash.

    Hi akashdeep,
    Nice question. I also tried to find out, but no much success. My opinion is that for practical purposes there is no difference.
    It may have difference in case of searching, especially sorted tables. (binary search or normal linear search).
    Case1: If our table is sorted table with defined key fields, and we give WITH TABLE KEY, then faster binary search is used.
    Case2 : If our table is sorted table with defined key fields, and we give WITH  KEY, (and no field contained in the keys), then normal linear search is used.
    regards,
    amit m.

  • How can I read two channels with fieldpoint and labview

    I'm trying to read two or more channels with the TC 120, and I follow the examples of sopport page, but doesn't work.
    What can I do?

    For more information about reading or writing to or from multiple channels in Fieldpoint, please refer to:
    How Do I Read or Write to Multiple Channels on a Fieldpoint Module in LabVIEW?
    This should enable you to read multiple channels. The only other option available is to use one fp open.vi, multiple Create Tag.vi's and multiple FP Tag Read.vi's.

  • Trying to sync iPhone 4 with itunes and get an error message PLEASE help

    I am currently using and iPhone 4. This morning I had synced my iPhone with itunes and it was working fine. I came home and wanted to add some music and such to it and all of a sudden i will plug it in to itunes and i,t looks like its going gets to step 2 of 6 (which is the back up process) and then an error message comes up saying itunes has stopped working, my only option to do is exit the window..
    Any ideas why this would be the case? its really frustrating me. I am also not the most computer savvy.
    Thanks

    Try reinstalling iTunes  http://www.apple.com/itunes/
    If that doesn't help, if you are using a Windows based computer, could be your anti virus software or your firewall that's preventing the sync.
    iTunes for Windows: Troubleshooting security software issues

  • Trying to make a payment with paypal and the page opens in German. Can't make a payment if I can't read the language. Browser is set correctly. Please advise

    Trying to make a payment on a website and the whole page is in German. Browser setting is English. Can't imagine why this would happen. Please advise...time sensitive.

    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox > Preferences > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox > Preferences > Privacy > Cookies: "Show Cookies"

  • Trying to create a dvd with video and slides...need help

    I am trying to make a dvd that includes video from my sister's wedding but I would also like it to include slideshows that I have already created in iDVD. Her wedding video was taken in to a shop and put onto a DVD. I would like to take the video from that DVD and combine it with my slideshows so that everything is on one disc. Plus, the menus (or lack thereof) from the DVD the shop made are HORRIBLE. Can someone tell me how to do this?
    Also, if you could explain how to insert chapters into the video once I have it into iDVD that would be appreciated. They did not include these on the DVD from the shop so it's one long movie with no way of skipping ahead short of fast forwarding.
    Thank you very much for any input.
    Michael

    Hi, Michael,
    I did for my daughter's wedding what you are trying to do for your sister's. You can do it this simple way:
    I took her wedding DVD and copied some of it onto DV tape and imported that into iMovie where I edited it down to some clips I wanted to go with the still photos I already had.
    To copy the DVD footage, I just put the disk into our DVD player, connected my camcorder and recorded it. Yes, there was a slight loss of quality, but not very detectable in the final product. After all, I am not a professional wedding videographer and some of the stills were from inexpensive snapshot cameras.
    The final video still turned out well.
    I actually did another longer one, this time using the original DV footage from the wedding videographer--he let us have it because he took so long to make the DVD! The DVD I made from that is of course better quality, but not that much better that I would go to more trouble to get it.

  • Reading a String with Scanner and ignoring whitespace

    Hi,
    This has probably been asked a million times, and I've searched Google and these forums, but I haven't found an answer that works for me.
    I have some class that needs to read user input from the command line, so I figured I'd use Scanner, since I've seen it used umpteen-hundred times in all the "do my homework" threads. I want to print out some line to the terminal, which will prompt the user to enter something. The user should then enter something and hit enter, and the Scanner should store the input in a variable of sorts.
    I've tried using Scanner.nextLine(), but that does not block for user input and the program terminates. I've tried Scanner.next() which does block for user input and allows the user to input something, but I cannot find a way to read the entire String; it will stop reading when it reaches whitespace. I've tried using a delimiter, but that seems to terminate the program when I prompt for the input, similar to Scanner.nextLine().
    Here's what I have at the moment:
    Scanner scanner = new Scanner(System.in); //I have also tried useDelimiter("\\s")
    System.out.print("Enter the desired command: ");
    String name = scanner.next();
    System.out.println("Command entered: " + name);The above code will work if the command is only one word, e.g. "connect". If the command is more than one word, it will only store the first word in the name variable. Again, I've tried using a delimiter for whitespace, but that hasn't worked.
    Is there a way to solve this problem? Perhaps I need to use another tool to read user input from the terminal? Am I just missing something? Do I need to explain more?
    Any advice is appreciated.
    Thanks

    I don't know why scanner.nextLine() doesn't work for you, it does for me with the following (copied) code:
    import java.util.Scanner;
    class Z
        public static void main(String[] args)
            Scanner scanner = new Scanner(System.in); //I have also tried useDelimiter("\\s")
            System.out.print("Enter the desired command: ");
            String name = scanner.nextLine();
            System.out.println("Command entered: " + name);
        }

  • Trying to read a file with Scanner

    This is the code:
              public void action(){
                   try{
                        Scanner sc = new Scanner(new FileReader("examples2.txt"));
                        String s;
                        while((s = sc.nextLine()) != null){
                             System.out.println(s);
                   catch(FileNotFoundException e){
                        System.out.println(e);
                     }Output:
    java.io.FileNotFoundException: examples2.txt (The system cannot find the file specified)Can anyone figure out why I am getting an exception? I know for a fact that the file exists and it exists in the same package as my class. I don't understand why it can't find the file. I have considered case sensitivity.
    Thanks

    SquareBox wrote:
    I would NOT be using Scanner for this type of io except that my assignment says that I have to. Just curious, why don't you like it?The API seems overly finicky to me; resulting in a lot of problems for newbies (at whom I understand the class was originally targeted) who end up using it incorrectly.
    Mind you, it's possible that I'm just an old dinosaur who prefers to read lines and then decide what I want to do with them myself.
    I tried this:
    Scanner sc = new Scanner(new BufferedReader(new FileReader("examples2.txt")));
    It works.What, when FileReader alone didn't? That seems odd.
    If I do that then do I have to flush the buffer? Or does it get flushed on it's own?I doubt whether it matters; flushing is generally only needed for output.
    Winston

  • HT1386 trying to sync my ipad with itunes and keep getting a message that itunes on my ipad needs to be v10.7 but ipad is brand new

    I am trying to sync my brand new ipad with my imac (itunes) and i keep getting a message to update itunes on my ipad.  how do i update software on my ipad? my ipad device is not displaying in itunes on my imac to be able to sync.  Can anyone advise?

    That message refers to iTunes on the computer and not anything on the iPad. If you're using a Mac, it needs to be running Mac OS X 10.6.8 or newer, which requires an Intel Mac with at least 1GB of RAM.
    (84478)

  • I was trying to update my Mac with software and the screen went white and it doesn't work at all now?

    I was installing snow leopard to my Mac and it took forever then I tried to get the Disc out and it did but the screen went completely white and isn't working at all now. Is there a way to fix this.?

    Which version of Mac OS X do you have?<br />
    Firefox 4 and later require at least OS X 10.5 and an Intel Mac.
    * http://www.mozilla.com/firefox/4.0/system-requirements/
    * http://www.mozilla.com/firefox/5.0/system-requirements/
    * http://www.mozilla.com/firefox/3.6/system-requirements/
    If you have problems with updating or with the permissions then easiest is to download the full version and trash the currently installed version to do a clean install of the new version.
    Download a new copy of the Firefox program and save the DMG file to the desktop
    * Firefox 5.0.x: http://www.mozilla.com/en-US/firefox/all.html
    * Firefox 3.6.x: http://www.mozilla.com/en-US/firefox/all-older.html
    * Trash the current Firefox application to do a clean (re-)install
    * Install the new version that you have downloaded
    Your profile data is stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder], so you won't lose your bookmarks and other personal data.

Maybe you are looking for

  • Query for Auto Calculation based on input of 2 Fields

    Hi, I would like to write a sql query to allow for auto calculation based on the Inputs of 2 other fields before Adding the Order. For example. A query on Sales Order where I have Item 040634 (Code for a Flower) and Quantity 200. I have a UDF (Bunchi

  • Java class files not found error in jsp sub-directories

    Hello: I have a web-application that is setup in the following way: index.jsp test\index1.jsp WEB-INF\classes\test.class Both jsp pages index.jsp and index1.jsp uses the test.class in the WEB-INF\classes directory. The index.jsp page works fine. The

  • How can I change the default start-up date for a new functional location?

    Is there a way to change the default date when creating a functional location? Whenever we create a new functional location, there is a date populated in the start-up date field. This date is our go-live date from last year and I cannot find the loca

  • Has anyone tried to install Oracle 11gR2 on Red Hat Linux 6 64bit?

    The Oracle Universal Installer is checking for some Red Hat packages which are not the ones in Linux 6. Does anyone know how to resolve this issue?

  • 8 Hours of Lightroom 2.1 on Windows 32bit

    Here's memory trace of LR 2.1 on Win32. I only had three crashers performing crop/rotate on 120 images. b Trace: http://www.night-ray.com/2008-12-20_1854.png Crash data: >12/20/2008 4:52:57 PM - Faulting application lightroom.exe, version 2.1.0.2, fa