How to write data to an XML file present under application server

frnds: can ne one tell me, how to write data in to a file, which is present under a application server
Ex: i want to write a string data in to a file test.txt which is present under "http://localhost:8080/<some_webapp>/test.txt"
Note:i have deploted a service<some_webapp> under Tomcat/webapps dir

Very simple. A servlet can writes to that file if it has the good rights.
In the servlet get (or post) method, use a code like this:
import java.io.*;
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
try {
String filePath = this.getServletContext().getRealPath("/text.txt");//See http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
         PrintWriter writer = new PrintWriter (filePath);
        //or BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
        writer .println("aString");
       writer.flush();
        writer .close();
    } catch (Exception e) {
       e.printStackTrace();
}Hope That Helps

Similar Messages

  • Issue: XML File Downloading to Application Server

    Hi All,
    I am experiencing an issue downloading an XML File to the Application Server.
    I'm using FM SAP_CONVERT_TO_XML_FORMAT to convert SAP data to XML Format.
    After getting the XML data into XMLTAB, I'm using:
    OPEN DATASET pfile_fs FOR OUTPUT IN BINARY MODE .
         LOOP AT xmltab INTO xmltab_w.
         TRANSFER xmltab_w TO pfile_fs.
          CLEAR xmltab_w.
         ENDLOOP.
       CLOSE DATASET pfile_fs.
    The xml file is downloaded show an Error in 'XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:/shared/TEST/2009'
    But when i download xml file using the FM  WS_Download , the XML page has no errors .
    I am unable to figure out what could be the issue, If this issue is due to some characters like Chinese or Japanese then .. is there any solution for this .
    Please, give me your valuable suggestions.
    Thank you,
    Prasead

    Dear Prasead,
            Hope things are good at your end, i have got the same issue as well, could you please care to share the solution...Wud be of a gr8 help if you could do that, hope to have your response back.
    Regards,
    Abdul.

  • Not able to open XML file in the application server..........

    Hi,
    I have downloaded a XML file to the application server.....
    File is created but i am not able to open the file there....
    Plz advice ....how to open it.....
    Regards.

    Use Notepad. Drag and drop in notepad.
    Aman

  • Creation of xml file in r3 application server (AL11)

    Hi All
    I need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy. As I tried with file adapter with FTP transport protocol. Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
    Thanks in advance
    Regards,
    Kartikeya

    Hi
    need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy.
    To generate file at AL11 file directory use File adapter. Proxy is not required for this
    Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
    1. Check with the Login credentials for the FTP service.
    2. FTP User you use in communication channel must have 777 access to FTP location.
    Thanks
    Gaurav

  • Error while extracting XML file from the application server

    Hi ,
    I am writing a XML file into the application server, after which when i try to extract the file to the local server using the report - RFASLDPC ,
    the file is extracted, but with a '#' symbol at the first position.
    Because of which the XML File does not open. But after i open the file in notepad and manually delete the '#' symbol and then reopen the file, it works fine.
    Is there any way to remove the '#' symbol while extracting itself ??
    Thanks in advance,
    Vikas.

    Select the option "No Character Set Conversion" in stead of Code page 1100.
    However, I still have troubles -> the downloaded xml file misses a space on several places. This causes errors too.

  • XML File opening in application server

    Hi sap Gurus,
    I am trying to open XML file in the application server  But it is giving dump,
    Please tell me why it is giving dump .
    Thanks,
    Prasad.

    Thanks ..... It is working .
    Thanks,
    Prasad.

  • How to update data in a xml file.

    I am able to retrieve data from a xml file but not able to update data. Also how can i add or delete node from a xml file.

    Hi,
    For some time I have also been trying to do the same thing with no success. So far I have tried a few approaches like $.post functions $.ajax post functions and HTML5 fileWriter functions. I am not well aware of the web development techniques but as fas as I understand the post or update of the json file should be done on the serverside mainly because of security issues. I am not sure how appbuilder works entirely and if there is any way to do this.
    Have you managed to find a solution ?
    (P.S. my goal is to update my chart data which is of course json file. So the idea here is to get some values from the user input and update the json file values then refresh the chart and display it with the new values).
    Best Regards,
    A.Dyankov.

  • How continuously write data to a txt file

    hello, 
    first of all, sorry for bad English, but I have a problem to continuously write data to the txt file.... I have one 2D array with values of some function and based on 2 sliders (values of the sliders) i want to interpolate value using bilinear method... and after that value of the sliders, interpolated value, and value of the nearest points i wish to write to txt file ... for every 2-3 seconds perhaps it would be ideal to be formated as :: 
    x   y   f     f1   f2   f3   f4
    but... first i have problem with writing data, because every time it deletes old data and just write new one and it's not horizontal... I'm very very new at this (it is obvious) and any help will be very appreciative  
    thanks  
    Solved!
    Go to Solution.
    Attachments:
    Proba.vi ‏21 KB

    Hi there,
    May I suggest you start with the LabVIEW tutorial?  Or perhaps this one?
    I say that because 1) you said you're new at this, and these tutorials are great for getting started; and 2) you don't seem to understand the concept of dataflow.
    A structure, such as a loop or subVI or function, cannot start executing until it has all of its inputs available.  Therefore, the loop which contains your file write (bottom loop) cannot execute until your top loop is done executing, because it depends on inputs from your top loop and those inputs aren't available until the top loop is finished.  Thus, your file will contain only the data from your final top loop execution.  You might be thinking that your loops are executing in parallel.  They are not.  Your file loop is executing after your data loop has finished...that is to say, your file loop executes exactly once, after you press your stop button.
    You can do two things here to fix that:
    1.  You can move your file write into the top (data) loop. (probably easier for now)
    2.  You can use a queue to transfer the data from your top (data) loop into your bottom (file write) loop. (more complex, but a better idea in the long run)
    One other thing.  Move the "open file" function outside the loop.  Opening and closing the file in each loop iteration will cause problems.  Open the file once.  Write to it in each loop iteration.  Close it when you're done.  Like this:
    Note that this is not complete code...you need to provide the data to write.  This is just to show you how to set up a continuous file write.
    Ok, start with the tutorials and we'll go from there. 

  • Write data to local xml file

    Does anyone know if there is a way to write data to a local xml file using the Connection refresh Button??

    Hi there Glenn,
    That's tricky...
    Are you using SP1?  You need to have at least SP1.
    The XLFs were generated with an internal build newer than SP1, but they should still work in earlier builds.
    If you changed the HTML file, that might be the cause.  The SWF references in the HTML file must be exact. 
    Also, the range names must match as defined in the XLF/SWF.  The bolded lines following should match.  It's easiest if they all use the SWF name.
    else if (hasRequestedVersion) {
    // if we've detected an acceptable version
    // embed the Flash Content SWF when all tests are passed
    AC_FL_RunContent(
    "src", "consumer",
    "width", "380",
    "height", "308",
    "align", "middle",
    "id", "consumer",
    "quality", "high",
    "bgcolor", "#ffffff",
    "name", "consumer",
    +"flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',+
    "allowScriptAccess","always",
    "type", "application/x-shockwave-flash",
    "pluginspage", "http://www.adobe.com/go/getflashplayer"
    } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
    'This content requires the Adobe Flash Player. '
    '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
    // -->
    </script>
    <noscript>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    id="consumer" width="380" height="308"
    codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
    <param name="movie" value="consumer.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="allowScriptAccess" value="always" />
    <embed src="consumer.swf" quality="high" bgcolor="#ffffff"
    width="380" height="308" name="consumer" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="always"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer">
    </embed>

  • How to write from database to XML file using JAVA and back..

    Hi....
    I am strugling for a code to write from database to xml output instead of what i have written in flat file....could anyone please help me out...to do this and again read the same back to the database using java...

    Hi,
    In java world, there is a tutorial on what you are looking for :
    http://www.javaworld.com/javaworld/jw-01-2000/jw-01-dbxml_p.html
    It uses SAX/DOM parsers to translate XML data into the appropriate fields of the database and visa-versa.
    Hope it helps.

  • How to Insert data from an XML file into an Oracle 10g table

    Hello,
    Please can you help me as I have hit a brick wall with this problem.
    We are running version 10g Oracle and we will start receiving XML files with employee data that needs loading into a table, this is the XML file:
    <?xml version="1.0"?>
    <RECRUITS>
    <RECRUIT>
    <FIRST_NAME>Gordon</FIRST_NAME>
    <LAST_NAME>Brown</LAST_NAME>
    <SHORT_NAME>GORDONBROWN</SHORT_NAME>
    <APP_NO>00002</APP_NO>
    <STATUS>M</STATUS>
    <DATE_FROM>21-JUL-2006</DATE_FROM>
    <RESOURCE_TYPE>P</RESOURCE_TYPE>
    <TITLE>Mr</TITLE>
    <DATE_OF_BIRTH>28-DEC-1983</DATE_OF_BIRTH>
    <SOCIAL_SEC>AB128456A</SOCIAL_SEC>
    <PARTTIME_PCT>1</PARTTIME_PCT>
    <SEX>M</SEX>
    <ADDRESS_TYPE>1</ADDRESS_TYPE>
    <ADDRESS>A HOUSE SOMEWHERE HERE</ADDRESS>
    <ZIP_CODE>PE3 LLL</ZIP_CODE>
    <PLACE>BOROUGH</PLACE>
    <COUNTRY_CODE>UK</COUNTRY_CODE>
    <PROVINCE>UK</PROVINCE>
    <EMAIL>[email protected]</EMAIL>
    </RECRUIT>
    (FYI - there may be more than 1 employee in each file so all of the above will be repeated X amount of times)
    </RECRUITS>
    To make things simple we have created a table which mirrors the XML file completely to load the data into, the SQL i have used is thus:
    CREATE TABLE RECRUITMENT
    FIRST_NAME VARCHAR2(30),
    LAST_NAME VARCHAR2(30),
    SHORT_NAME VARCHAR2(30),
    APP_NO NUMBER,
    STATUS VARCHAR2(1),
    DATE_FROM DATE,
    RESOURCE_TYPE VARCHAR2(1),
    TITLE VARCHAR2(4),
    DATE_OF_BIRTH DATE,
    SOCIAL_SEC VARCHAR2(9),
    PARTTIME_PCT NUMBER,
    SEX VARCHAR2(1),
    ADDRESS_TYPE VARCHAR2(1),
    ADDRESS VARCHAR2(30),
    ZIP_CODE VARCHAR2(8),
    PLACE VARCHAR2(10),
    PROVINCE VARCHAR2(3),
    EMAIL VARCHAR2(20)
    Every method we try from the numerous documents and so called "user guides" have failed, please can somebody show me the PL/SQL i need to get this files data into the above table?
    We need to be able to do this purely through SQL*PLUS as we hope - if we ever get it working manually to create a procuedure that will encapsulate everything so it can be run over and over again.
    The XML file is sitting in the XMLDIR and is called REC.XML.
    Please help : (

    Hi, I have got some material for inserting data into oracle table from xml file, this might help you.
    Create XML Document Table
    create table XML_DOCUMENT_TABLE
    FILENAME varchar2(64),
    XML_DOCUMENT XMLTYPE
    (This will be as per your record details).
    Inserting record to Oracle Table
    declare
    XML_TEXT CLOB := '<smsnotification>
                   <messageid> 256427844 </messageid>
              <protocolid> CO0NPS2KHQ </protocolid>
              <notifiedon> 1156123007416 </notifiedon>
              <status> 3PBI: Invalid </status>
    <additionalinfo> Customer account not active </additionalinfo>
    <carrierid> 1175 </carrierid>
    </smsnotification>';
    begin
    insert into XML_DOCUMENT_TABLE values ('Receipt.xml',XMLTYPE(XML_TEXT));
    end;
    Select Statement
    select extractValue(XML_DOCUMENT,'/smsnotification/messageid') Messageid,
    extractValue(XML_DOCUMENT,'/smsnotification/status') Status,
    extractValue(XML_DOCUMENT,'/smsnotification/carrierid') CarrierID
    from XML_DOCUMENT_TABLE;

  • How to write multiple ejb-jar.xml file in an ejb module

    i am developing an ejb project. I hav a number of entity beans and session beans and their mapping in ejb-jar.xml. As the number of beans increases the entry of beans and mapping is also increasing. So i want to ask u that is there any mechanism so that i can divide the ejb-jar.xml file so that it will be easy to maintain it.

    ejb-jar is the smallest composable unit for related EJB components. Your best bet is to create multiple ejb-jars and package them within the same enterprise application (.ear).

  • Where is the UME data source configuration XML file stored on the server?

    I'm trying to activate windows integrated authentication in my portal server.  The java engine's UME configuration has been loaded as a deep AD read only database using the file "dataSourceConfiguration_ads_deep_readonly_db.xml" but I can't find this on my server.  I need to modify a couple of parameters in there to activate kerberos principal management.  My recent portal training course offered me a completed working example but it was for an ads_flat_writeable_db so I can't simply load that and I need to understand the changes required.
    Where to I find the configuration file on my java instance server so I can make the necessary changes to a copy and upload that?

    Try to read
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e1959b90-0201-0010-849c-d2b1d574768b
    UME user data is stored in one or more data sources. Each type of data source has its own persistence adapter. The persistence manager consults the persistence adapters when creating, reading, writing, and searching user management data. Persistence adapters for the following types of repositories are available: 1. Database: See the Product Availability Matrix on SAP Service Marketplace (http://service.sap.com/pam60) for details on which databases are supported. 2. u2022 Lightweight Directory Access Protocol (LDAP) directory: See the Product Availability Matrix on SAP Service Marketplace (http://service.sap.com/pam60) for details on which directories are supported. 3. SAP Systems based on Web Application Server 6.20 You can configure UME to use one or more of these persistence devices in parallel. Users can also be stored in several different physical LDAP directory servers, or in different branches of the same LDAP directory server.

  • How to save 4 versions of a file in the application server

    Hi,
       I have to write a program which will extract few data from SAP and write it in a file in the SAP application server. This program will be run once every month.
    I need to save 4 versions of the files, current and 3 prior.  These versions should cycle off the oldest once a new version has been created.
    Could anyone help me how to do this?
    Thank you!
    Regards,
    Sunitha.

    Hi Sunitha,
    The best way is to write a unix script in the unix server to do the job for you. Once The file is written in the server then leave the job from the unix side to get this done.
    This is the best option i think. Writing a script is not a big task. You can call the script from ABAP or from an external daemon in the unix server. We have many such programs in our org.
    Hope this helps
    Cheers
    VJ

  • XML file in the Application server

    Hi all
    I am transferring the XML data in to application server but it is not transferring complete data .
    why it is not transferring complete data please tell me.
    Points will  be rewarded .
    Thanks.
    Prasad.

    tables: t005s,
            a911 ,
            konp .
    data: begin of it_t005u occurs 0,
            bland like t005u-bland,
            bezei like t005u-bezei,
          end  of  it_t005u .
    data: begin of it_a911 occurs 0,
           regio like a911-regio,
           knumh like a911-knumh,
          end  of  it_a911 .
    data: begin of it_konp occurs 0,
           knumh like konp-knumh,
           kbetr like konp-kbetr,
          end  of  it_konp .
    data: begin of it_download occurs 0,
            string(54),
          end   of it_download.
    data: it_textno like zdms_textno occurs 0,
          wa_textno like line of it_textno   .
    data : gv_filenum like zdms_textno-filenumber  ,
           gv_filenumc(10) type c .
    data: gv_file1 type string.
    data: f1(2),
          f2(2),
          f3(2),
          gv_vat_app(1),
          gv_kbetr(12) .
    *********Start of Inserted by Durai.V 26-May-2008 *****
    data : w_app_ser_nme type msxxlist-name value 'r3prod_EEP_05'.
    data : lv_flag_con type c.
    data : it_download_app_ser like dxrawdata occurs 0.
    *********End of Insert by Durai.V 26-May-2008 *********
    start-of-selection.
      select bland
             bezei
        into table it_t005u
        from t005u
       where spras eq 'EN'
         and land1 eq 'IN'.
      if not it_t005u[] is initial.
        select regio
               knumh
          into table it_a911
          from a911
           for all entries in it_t005u
         where kschl eq 'JIVP'
           and regio eq it_t005u-bland
           and taxk1 eq '1'
           and taxm1 eq 'A'
           and datbi ge sy-datum
           and datab le sy-datum .
      endif.
      if not it_a911[] is initial.
        select knumh
               kbetr
          into table it_konp
          from konp
           for all entries in it_a911
         where knumh eq it_a911-knumh.
      endif.
      it_download-string = 'STATE' .
      append it_download .
      clear it_download .
      it_download-string = '{' .
      append it_download .
      clear it_download .
      loop at it_t005u.
        clear: it_a911,
               it_konp,
               gv_vat_app,
               gv_kbetr.
        read table it_a911 with key regio = it_t005u-bland.
        if sy-subrc = 0.
          read table it_konp with key knumh = it_a911-knumh.
          if sy-subrc = 0.
            gv_vat_app = 'Y' .
          else.
            gv_vat_app = 'N' .
          endif.
        endif.
        if ( it_t005u-bland ne '' ).
          gv_kbetr = it_konp-kbetr / 10 .
          if it_t005u-bezei eq ''.
            f1 = ' ~'.
          else.
            f1 = '~'.
          endif.
          if gv_vat_app eq ''.
            f2 = ' ~'.
          else.
            f2 = '~'.
          endif.
          if gv_kbetr eq ''.
            f3 = ' ~'.
          else.
            f3 = '~'.
          endif.
          concatenate 'STATE'
                      '~'
                      '001'
                      '~'
                      it_t005u-bland
                      '~'
                      it_t005u-bezei
                      f1
                      gv_vat_app
                      f2
                      gv_kbetr
                      f3
                 into it_download-string.
          append it_download .
          clear  it_download .
        endif.
      endloop.
      if sy-subrc = 0.
        lv_flag_con = 'X'.
      endif.
      it_download-string = '}' .
      append it_download .
      clear  it_download .
      clear:  gv_filenum ,
               gv_filenumc,
               gv_file1   ,
               wa_textno  .
      select single filenumber
             from   zdms_textno
             into   gv_filenum
             where  filename eq 'DMS_' .
      move  gv_filenum to gv_filenumc  .
      shift gv_filenumc left deleting leading '0'.
       if gv_filenum < 10 .
         concatenate '0' gv_filenumc into gv_filenumc .
       endif.
      concatenate 'DMS_'
                  gv_filenumc
                  '.txt'
             into gv_file1 .
    *Downloading the file to Application Server**
    Start of Commented by Durai.V 26-May-2008 **********
    *open dataset gv_file1 for output in text mode ENCODING DEFAULT  .
       loop at it_download.
         transfer it_download-string to gv_file1.
       endloop.
    *close dataset gv_file1.
    End of Commented by Durai.V 26-May-2008 ************
    *********Start of Inserted by Durai.V 26-May-2008 *********
      data : lv_serv_file_pth type dxfile-filename.
      lv_serv_file_pth = gv_file1.
      it_download_app_ser[] = it_download[].
      if it_download_app_ser[] is not initial and lv_flag_con = 'X'.
        call function 'DX_FILE_WRITE'
          exporting
            filename            = lv_serv_file_pth
            server              = w_app_ser_nme
            pc                  = ''
          tables
            data_tab            = it_download_app_ser[]
          exceptions
            no_file_on_server   = 1
            no_data_on_server   = 2
            gui_download_failed = 3
            no_authority        = 4
            others              = 5.
    *********End of Inserted by Durai.V 26-May-2008 ***********
        if sy-subrc = 0.
          wa_textno-filename   = 'DMS_'         .
          wa_textno-filenumber = gv_filenum + 1 .
          modify zdms_textno from wa_textno .
        endif.
      else.
        write / 'No Data Selected, So file not created in Appllcation Server'.
      endif.
    check this report ........it is doing the same
    reward IF...................
    Regards
    Anbu

Maybe you are looking for