Reading file content using Javascript

Hi Friends,
is it possibel to read the contents of the child window opened from a javascript.for example am opening a window using Window.open function in javascript, after opening the window can i read the contents ?If so how can anyone help in this.
Thanks
Vishy

Below is the code of my normal java program which works fine.
try {
// File destFile = new File("./SourceFiles/savedFile.txt");
File destFile = new File("./SourceFiles/", "savedFile.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(destFile));
writer.write("TESTing File Save");
writer.flush();
System.out.println("SAVED!!");
} catch ( IOException e ) {
e.printStackTrace();
Structure of this project is
Samples
|SaveSample
|SaveSample.java
|SourceFiles
|savedFile.txt
I have implemented similar code in my servlet too. But this doesnt save the content to the HTML file.
protected void doPost(HttpServletRequest request,
               HttpServletResponse response) throws ServletException, IOException {
          action = request.getParameter("action");
          try {
File destFile = new File("./SourceFiles/", "savedFile.html");
BufferedWriter writer = new BufferedWriter(new FileWriter(destFile));
writer.write(action);
writer.flush();
System.out.println("SAVED!!");
} catch ( IOException e ) {
e.printStackTrace();
Im getting FileNotFound Exception
java.io.FileNotFoundException: .\SourceFiles\savedFile.html (The system cannot find the path specified)
     at java.io.FileOutputStream.open(Native Method)
     at java.io.FileOutputStream.<init>(Unknown Source)
     at java.io.FileOutputStream.<init>(Unknown Source)
     at java.io.FileWriter.<init>(Unknown Source)
     at savepackage.SaveContent.doPost(SaveContent.java:81)
Edited by: 849224 on Apr 5, 2011 4:17 AM

Similar Messages

  • Reading child window contents using Javascript

    Hi Friends,
    is it possibel to read the contents of the child window opened from a javascript.for example am opening a window using Window.open function in javascript, after opening the window can i read the contents ?If so how can anyone help in this.
    Thanks
    Vishy

    Am sorry , but there are courteous ways to say this.
    Anywya never mind .SOrry if i have taken more traffic
    with this irrelevant questionI'm not trying to be rude. I'm just suggesting that you'll get better replies on a JavaScript forum.

  • Generate an xml-file by using javascript

    Hi,<br /><br />i'm working on a form with Adobe Designer.<br /><br />My goal is to generate my own xml file using javascript, attach this to mail also generated by using javascript (app.mailMsg(false, "<mail address>", "", "", "<mail subject>", "<mail body>" --> this works already :-)) and send it.<br /><br />By now i have:<br /><br />---------------- my code --------------------------------------<br /><br />var container = "";<br /><br />container = "<?xml version="1.0" encoding="UTF-8"?>\n";<br />container = container + "<header>\n";<br />container = container + "<author> author name</author>\n";<br />container = container + <authorMail>my mail</authorMail>\n";<br />container = container + "</header>\n";<br />container = container + "<Daten>\n";<br />container = container + "<name>" + field.value + "</name>\n";<br />container = container + "<adresse>" + field.value + "</adresse>\n";<br />container = container + "<ort>" + field.value + "</ort>\n";<br />container = container + "<staat>" + field.value + "</staat>\n";<br />container = container + "<plz>" + field.value + "</plz>\n";<br />container = container + "<land>" + field.value + "</land>\n";<br />container = container + "</daten>\n";<br /><br />---------------- end of my code -------------------------------<br /><br />This works fine, and i have my xml content in the var container.<br />After that i try this:<br /><br />---------------- my code --------------------------------------<br /><br />var myDoc = event.target;<br />myDoc.createDataObject("filename.xml", container);<br />myDoc.exportDataObject("filename.xml");<br /><br />---------------- end of my code -------------------------------<br /><br />Instead of event.target i write down click.Form1<br />This doesn't work at all :-( anyone an idea?<br /><br />Lots of thanks for your help,<br />aldo

    Hi everybody,<br /><br />the code works good now. so it should be available for everybody who needs it:<br /><br />---------------- my code --------------------------------------<br /><br />var container = "";<br /><br />container = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";<br />container = container + "<all>\n";<br />container = container + "<header>\n";<br />container = container + "<author>author name</author>\n";<br />container = container + "<authorMail>[email protected]</authorMail>\n";<br />container = container + "</header>\n";<br />container = container + "<body>\n";<br />container = container + "<name>" + value + "</name>\n";<br />container = container + "<adresse>" + value + "</adresse>\n";<br />container = container + "<ort>" + value + "</ort>\n";<br />container = container + "<staat>" + value + "</staat>\n";<br />container = container + "<plz>" + value + "</plz>\n";<br />container = container + "<land>" + value + "</land>\n";<br />container = container + "</body>\n";<br />container = container + "</all>\n";<br /><br />var myDoc = event.target;<br />myDoc.createDataObject("export.xml", container);<br />myDoc.exportDataObject("export.xml");<br /><br />app.mailMsg(false, "mail-address1; mail-address2", "", "",<br />"mail subject", "mail body");<br /><br />---------------- end of my code ------------------------------- <br /><br />now i'm looking for a solution to automatically attach the file to this mail and directls sent it without to call up the mail client.<br />if anybody has got an hint, you're welcome ;-)

  • How to add do not read file content option inside File Adapter (Synch Read)

    Hi,
    Is there any way, that I can skip reading the file content inside file adapter with operation as Synchronous Read ( I just want to read the file name and directory and if the file name matches with the input variables then I have to delete the files, for this i am using FA with synch read operation, everything is fine like deletion, but it is reading the file content and storing it in DB, i dont want this) .

    This will solve your problem.
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CHDHIEBI
    HTH.
    Puneet.

  • Read file content and keep binary copy

    Hi All,  I don't know what the best way of doing this is, but my requirement is to read the content of a file using File Adapter and post a document with this datda in SAP, but also to keep a binary copy of the file attached to the posted document.
    So my question is, Is there a way within the file adapter to read the content of the file using the Content Conversion mechanism and at the same type keep a binary copy of the read file.
    Thanks,
    Pablo

    Hi,
    I know we can send it via proxy but your question was something different or my be I misunderstood it.. here is your question again..
    >
    Pablo Lopez wrote:
    > Hi All,  I don't know what the best way of doing this is, but my requirement is to read the content of a file using File Adapter and post a document with this datda in SAP, but also to keep a binary copy of the file attached to the posted document.
    > So my question is, Is there a way within the file adapter to read the content of the file using the Content Conversion mechanism and at the same type keep a binary copy of the read file.
    >
    > Thanks,
    > Pablo
    What I understood from your question that, there is a file which you want to read/pick via file adapter and at the same time you also want to attach same file along with the content and then post it to R3.
    If my assumption is correct then it is not possible. Yeh If there is some workaround then that is different story.
    Regards,
    Sarvesh

  • Problem in reading file contents in to inernal table

    i have  a problem with the archive file
    actually i have created archive files in SAP file system i stored the archive file in a external repository.
    now i like to access one of the archive file i want to read the contents of the file in to a internal table.
    the starting of the file contains some unique document number i need to able to capture that document number.
    i am able to read the contents from archive file but the contents are unknown charecters.
    i used open data set to read the contents of the file , but i cannot resolve these unknown charecters.

    Call transactions
    - SARA Archive Administration
    - AOBJ to find the read program (if exists) associated to the archive object
    More information on [Archive Administration|http://help.sap.com/saphelp_smehp1/helpdata/en/8d/3e4d70462a11d189000000e8323d3a/frameset.htm] and [Archive Development Kit|http://help.sap.com/saphelp_smehp1/helpdata/en/2a/fa0391493111d182b70000e829fbfe/frameset.htm]
    Regards,
    Raymond

  • Add file contents using drag drop method

    I want to add file contents to a text view by drag drop method. How i can do that in cocoa using objective c? Can anybody help me. I am using following code in my appCotroller file to do the same but can't get the desired out put. Insted of getting file contents, i m getting the file URL (Path) in the text view.

    shaktirsg wrote:
    As you said i have to open that file in my performDragOperation function, I want to know where to write this function. bcoz i have written this function in my appCotroller class but that code does'n get executed. Can you help me on this.
    It is very hard to debug code I haven't seen. If you are getting the URL in your text view, you must be handling the drag operation correctly. Instead of putting the pasteboard data into the text view, get the file's contents and put that into the text view.
    Also can you give me a sample code on how to open files in coccoa, how to read the contents of that file?
    Look at NSString's "stringWithContentsOfFile:encoding:error:"

  • How to print a text file contents using java.

    Using Input and Output streams I can add and retrive the contents to/from text file. But how to send this file contents to the printer or how to print the file.

    Example from my code:
       private void printErrorReport()
          PrintJob pjob = getToolkit().getPrintJob(m_frame,null,null);
          if (pjob != null) {
            Graphics pg = pjob.getGraphics();
            if (pg != null) {
              String s = detailsArea.getText();
              printLongString (pjob, pg, s);
              pg.dispose();
            pjob.end();
    // Utility method needed
       void printLongString (PrintJob pjob, Graphics pg, String s) {
         int pageNum = 1;
         int linesForThisPage = 0;
         int linesForThisJob = 0;
         // Note: String is immutable so won't change while printing.
         if (!(pg instanceof PrintGraphics)) {
           throw new IllegalArgumentException ("Graphics context not PrintGraphics");
         StringReader sr = new StringReader (s);
         LineNumberReader lnr = new LineNumberReader (sr);
         String nextLine = "       ";
         int pageHeight = pjob.getPageDimension().height;
         pageHeight -= 20;
         Font helv = new Font("Arial", Font.PLAIN, 12);
         //have to set the font to get any output
         pg.setFont (helv);
         FontMetrics fm = pg.getFontMetrics(helv);
         int fontHeight = fm.getHeight();
         int fontDescent = fm.getDescent();
         int curHeight = 0;
         try {
           do {
             nextLine = lnr.readLine();
             if (nextLine != null) {
               if ((curHeight + fontHeight) > pageHeight) {
                 // New Page
                 System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
                 pageNum++;
                 linesForThisPage = 0;
                 pg.dispose();
                 pg = pjob.getGraphics();
                 if (pg != null) {
                   pg.setFont (helv);
                 curHeight = 0;
               curHeight += fontHeight;
               if (pg != null) {
                 pg.drawString (nextLine, 0, curHeight - fontDescent);
                 linesForThisPage++;
                 linesForThisJob++;
               } else {
                 System.out.println ("pg null");
           } while (nextLine != null);
         } catch (EOFException eof) {
           // Fine, ignore
         } catch (Throwable t) { // Anything else
           t.printStackTrace();
         System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
         System.out.println ("pages printed: " + pageNum);
         System.out.println ("total lines printed: " + linesForThisJob);
         }

  • Help reading file contents

    Hi,
    I have a file with these contents
    �One�
    Hello Man. h
    �Two�
    This is the body of the message, which can go on for as long as possible.
    which can go on for as long as possible. This is the body of the message, which can go on for as long as possible. This is the body of the message, which can go on for as long as possible.
    MessengerI am using this code to read the contents of the file
    try
         DataInputStream msgFile = new DataInputStream(new FileInputStream(fileName));
         String str = "";
         while((str=msgFile.readLine())!= null)
               if(str.equalsIgnoreCase("�One�") )
                     String one = msgFile.readLine().trim();
               if(str.equalsIgnoreCase("�To�") )
                     String two = msgFile.readLine().trim();
    }           When I try to print String "two", I get only
    This is the body of the message, which can go on for as long as possible. as I am using readLine() method
    Is there a way I can solve this problem to read until the end of the file?
    Mathew

    try something like this
    BufferedReader in = new BufferedReader(new FileReader(fileName));
          data = in.readLine();
          while (data != null) {
             // Here is your line, do what ever you want to do
             data = in.readLine();
          }

  • Retrieving and Resetting textEdit Content Using JavaScript

    I need to retrieve the content within a textEdit box using JavaScript, and then append a String to that content, and re-enter that content as the inner content of a textEdit box.  Does anyone know how to do this? 
    I tried using jsObjectNeeded for textEdit, but it is an invalid parameter for that object.  I also tried grabbing the ID in a round-about way in JavaScript using _1texteditor or _1htmlbeditor, but I get an "Object Expected" error everytime.
    Here is the item I am working with, and within my JS method, I need to grab the text inside, append a string to it, and reset that new content as the text within the edit box.
    <hbj:textEdit id="summaryBox"
       text="Add summary here."
       wrapping="SOFT"
       tooltip="Add summary here."
       rows="5"
       cols="70">
    This is the content inside the box.
    </hbj:textEdit>
    Thanks in advance for your help...

    Thank you for your help, guys, but neither suggestion solved my problem and I solved it on my own.  You have to find the parameter ID through a line of Java, like Damian had mentioned about an ID, but I was looking for the value within the textEdit, not the ID. 
    In the JavaScript method, you set a variable to the Java variable, which found the parameter ID.
    Then, using that JS variable, you do:
    var blah = <%=javaParameterId%>;
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    var textEditField = eval(htmlb_formid + "." + blah);
    var wordsWithTexEdit = textEditField.value;
    Thanks anyways...

  • Reading HTML Content using Web Dynpro ABAP

    Hello,
    I was wondering if it is possible to read the content (HTML) behind a given URL using Web Dynpro ABAP.  If so, are there any functions available to parse the HTML ?   I have been asked to develop an application that requires going to a URL, reading the content, and formatting a table from that content for presentaion within Web Dynpro ABAP.  The HTML of the URL is nothing more than a "Table of Contents" to existing documentation ( Word Documents )
    Thank you for any help / advice you can provide
    Larry

    You can get the HTML returned in a table using fm RSFO_HTML_REQUEST2.
    Once you have that, you can convert it to a string using any number of methods. CL_RSR_WWW_RENDERER=>TABLE_TO_STRING should work fine.
    One option for parsing it would be to get it converted into an iXML object, but you might have to do quite a bit of manipulation first depending on what the html looks like. You can see more info here on iXML classes: [http://help.sap.com/saphelp_nw04/helpdata/de/86/8280ba12d511d5991b00508b6b8b11/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/de/86/8280ba12d511d5991b00508b6b8b11/frameset.htm]
    Otherwise I would just make use of find statements with regex patterns to sort through the html.

  • Reading file content into internal table

    Hi All,
    I'm facing problem reading pdf file content into an internal table. I need to read this file from communication server (neither presentation nor application server). I have tried gui_upload , it is working fine but it does not work in batch jobs. Open dataset in binary mode is also not helping much. Could anyone help ?
    Thanks a lot

    "open dataset <filepath> for input in binary mode" should work.... what does it say when you try this?
    Thanks
    Muktar

  • Reading form data using javascript

    Hello.
    I want to go over the data received from the context to the PDF file using JavaScript, without binding it to any elements on the form.
    How can I access the data?
    I've tried using xfa.data or xfa.dataset, but didn't manage to get to it.
    How can it be done?
    Thanks.

    The following applies if it's a PDF generated from ABAP :
    Let's say a simple type parameter from context is named EBELN. To get it from javascript, you must use :
    $data.data.EBELN.value
    or
    $record.EBELN.value
    (it's the same)
    For example, to display the value, use:
    xfa.host.messageBox( $data.data.EBELN.value );
    Edited by: Sandra Rossi on Jan 28, 2009 7:34 PM : added $record line

  • Reading file anf using input for main

    Hello Amigos,
    I have the following code but I have my doubts if it will work for what I want. I want to read in a file that will call a method with specific arguments.
    Example:
    Method:
    addTwoNumbers(int oneNum, int twoNum);
    File: sum.txt:
    addTwoNumbers(1,5);
    addTwoNumbers(8,2);
    addTwoNumbers(3,10);
    My confusion starts with the PrintWriter definition. I am not quite sure how to implement it and I don't find an example or online reference about this topic.
    Thanks in advance...
    try
                BufferedReader fileIn  = new BufferedReader( new FileReader("process.txt"));
                String oneLine;
                System.out.println("Reading File...");
              while( ( oneLine = fileIn.readLine( ) ) != null )
                   PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(fileIn.readLine()));
                      printWriter.println(oneLine);
                      printWriter.close();
                      System.out.flush();
                 System.out.println("Done Reading File.");
            }

    It's hard to tell where to start. I'll post a brief example of how to read something in from a text file and use it. It's not robust, but it serves as a starting point, I suppose.
    sum.txt
    1,3
    2,4
    5,6
    SumDemo.javaimport java.io.*;
    public class SumDemo
        public static void main(String[] args)
            new SumDemo().go();
        public void go()
            String fileName = "sum.txt";
            try {
                BufferedReader in = new BufferedReader(new FileReader(fileName));
                String line;
                while ((line = in.readLine()) != null)
                    String[] nums = line.split(",");
                    int x = Integer.parseInt(nums[0]);
                    int y = Integer.parseInt(nums[1]);
                    System.out.println(addTwoInts(x, y));
            catch (IOException ioe) { ioe.printStackTrace(); }
        public int addTwoInts(int x, int y)
            return x + y;
    }

  • WebDynpro: How to read file content?

    Hi,
    My business scenario requires:
    1, The file name is passed in through inbound plug parameter
    2, I need to read the file content and then attach it to my CRM transaction
    Please share with me how to read the file content.
    The following approaches do not fit my scenario:
    1, UI element: FileUpload
    The reason is obvious: there is only file name parameter instead of any UI interface
    2, Function Module: GUI_UPLOAD
    The reason is that dump will happen in WebDynpro environment
    Thanks & Best Regards,
    David

    HI,
    Refer these links  -
    Get content document in WD abap
    Excel File to Internal Table

Maybe you are looking for

  • How can i reinstall itunes 10.5.2 on windows xp, after i deleted the older version? help please!

    it's been painfull not to get the answer for this issue, since i did update every single apple features that works with my pc windows xp, thi's the 1rst time that i have this problem! anyone out there can help pleeeaasseee?????

  • Disappearing Effects from Process....Effects menu

    Greetings. I've been using Soundtrack Pro for a long time, but for some reason now I have no submenu for Process...Effects. If I click on the Process menu, then drag down to Effects>, no submenu appears. This is when editing a file (and not in multit

  • Show a picture in a front panel

    Hello All, I want to display a image (that is in another front panel) when i press a buttom in the main front panel. Then I want to close the image clicking in a buttom in the second panel and return to the fist front panel. I don´t know how to do it

  • Is there an eta on rein faults or do BT just fob y...

    I've had a faulty line for officially about 4 months now since I refuse to let them close this case since its ongoing and not fixed. Unofficially I suspect it's been faulty for about a year as I stopped heavy Internet use a little while before that b

  • Controlling the volume tone when the Mac boots

    Hi, The tone (or beep?) the Mac makes when it initially boots up appears to be controlled by the internal speaker volume setting. So, if the last thing I did before shutting down was listen to something that was very soft and the volume adjusted high