Skip to main content
Inspiring
March 6, 2017
Answered

How to Read a .txt file on server using Java?

  • March 6, 2017
  • 1 reply
  • 746 views

Hello

Cap9. HTML5 only. Server=Linux(LAMP). No LMS.

I have a text file on the server named golive.txt which contains a single item of text, either the letter "Y" or "N".

When the Captivate project starts I need the project to read the text file.

If the text is "Y" I need a button in Captivate to be shown.

How can I do this?

I assume I will have to use Execute Javascript when the project starts.

I looked on the internet for Javascript examples of how to read a text file from a server, but they all seem to be too complicated, (arrays, libraries, etc), for such a simple need.

I don,t need to check for the file, it will be there.

I don't need to write to the file.

I don't need to display the contents.

Any help or suggestions will be much appreciated.

Thank you

Peter.

    This topic has been closed for replies.
    Correct answer petern33480613

    I figured it out.

    Put on a Web Object pointing to golive.txt

    Use Java to get the content of Web Object.

        var myIFrame = document.getElementsByTagName("iframe")[0];

        var content = myIFrame.contentWindow.document.body.innerHTML;

         alert(content);

    1 reply

    Inspiring
    March 6, 2017

    I had a thought.

    If I use a Web Object to view the golive.txt file, I will have the text on a slide.

    How can I read the content of the Web Object in Java?

    Thanks.

    petern33480613AuthorCorrect answer
    Inspiring
    March 6, 2017

    I figured it out.

    Put on a Web Object pointing to golive.txt

    Use Java to get the content of Web Object.

        var myIFrame = document.getElementsByTagName("iframe")[0];

        var content = myIFrame.contentWindow.document.body.innerHTML;

         alert(content);