How to download files by using applet?

Hello folks,
I am new to applet, and I want to write an applet to download multiple files from the applet-hosting server by using HTTP or socket. Any idea to achieve that? Using java.net.HttpURLConnection? or others?
Appreciate your helpful replies.
Joe

In either Applet or AppletContext you should find 2 methods
getCodeBase()
getDocumentBase()
it is possible that those methods may return the same URL although they might not depending on how everything's set up. But anyway you can use that to get a URL and use the URL to open a connection

Similar Messages

  • How to download files by using ipad

    How to download the pictures or files from ipad4 using safari browser,it always says it cannot be downloaded
    What alternative is available to solve this issue

    In either Applet or AppletContext you should find 2 methods
    getCodeBase()
    getDocumentBase()
    it is possible that those methods may return the same URL although they might not depending on how everything's set up. But anyway you can use that to get a URL and use the URL to open a connection

  • How to download file from application server

    Hi Experts,
                  I developed report and execute in background mode. for this i used Open dataset transfer and close dataset . i got the requried output . But in this case user want downloaded file on presentation server so can anyone tell me How to download file from application server?
    i know it is possible through Tcode CG3Y. but i want code in program.

    This code will download a file to your Client package by package, so it will also work for huge files.
    *& Report  ZBI_DOWNLOAD_APPSERVER_FILE
    REPORT  zbi_download_appserver_file.
    PARAMETERS: lv_as_fn TYPE sapb-sappfad
    DEFAULT '/usr/sap/WBP/DVEBMGS00/work/ZBSPL_R01.CSV'.
    PARAMETERS: lv_cl_fn TYPE string
    DEFAULT 'C:\Users\atsvioli\Desktop\Budget Backups\ZBSPL_R01.CSV'.
    START-OF-SELECTION.
      CONSTANTS blocksize TYPE i VALUE 524287.
      CONSTANTS packagesize TYPE i VALUE 8.
      TYPES ty_datablock(blocksize) TYPE x.
      DATA lv_fil TYPE epsf-epsfilnam.
      DATA lv_dir TYPE epsf-epsdirnam.
      DATA ls_data TYPE ty_datablock.
      DATA lt_data TYPE STANDARD TABLE OF ty_datablock.
      DATA lv_block_len TYPE i.
      DATA lv_package_len TYPE i.
      DATA lv_subrc TYPE sy-subrc.
      DATA lv_msgv1 LIKE sy-msgv1.
      DATA lv_processed_so_far TYPE p.
      DATA lv_append TYPE c.
      DATA lv_status TYPE string.
      DATA lv_filesize TYPE p.
      DATA lv_percent TYPE i.
      "Determine size
      SPLIT lv_as_fn AT '/' INTO lv_dir lv_fil.
      CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
          file_name      = lv_fil
          dir_name       = lv_dir
        IMPORTING
          file_size_long = lv_filesize.
      "Open the file on application server
      OPEN DATASET lv_as_fn FOR INPUT IN BINARY MODE MESSAGE lv_msgv1.
      IF sy-subrc <> 0.
        MESSAGE e048(cms) WITH lv_as_fn lv_msgv1 RAISING file_read_error.
        EXIT.
      ENDIF.
      lv_processed_so_far = 0.
      DO.
        REFRESH lt_data.
        lv_package_len = 0.
        DO packagesize TIMES.
          CLEAR ls_data.
          CLEAR lv_block_len.
          READ DATASET lv_as_fn INTO ls_data MAXIMUM LENGTH blocksize LENGTH lv_block_len.
          lv_subrc = sy-subrc.
          IF lv_block_len > 0.
            lv_package_len = lv_package_len + lv_block_len.
            APPEND ls_data TO lt_data.
          ENDIF.
          "End of file
          IF lv_subrc <> 0.
            EXIT.
          ENDIF.
        ENDDO.
        IF lv_package_len > 0.
          "Put file to client
          IF lv_processed_so_far = 0.
            lv_append = ' '.
          ELSE.
            lv_append = 'X'.
          ENDIF.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              bin_filesize         = lv_package_len
              filename             = lv_cl_fn
              filetype             = 'BIN'
              append               = lv_append
              show_transfer_status = abap_false
            TABLES
              data_tab             = lt_data.
          lv_processed_so_far = lv_processed_so_far + lv_package_len.
          "Status display
          lv_percent = lv_processed_so_far * 100 / lv_filesize.
          lv_status = |{ lv_percent }% - { lv_processed_so_far } bytes downloaded of { lv_filesize }|.
          CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
            EXPORTING          "percentage = lv_percent - will make it fash
              text = lv_status.
        ENDIF.
        "End of file
        IF lv_subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      "Close the file on application server
      CLOSE DATASET lv_as_fn.

  • How to move downloaded files from download folder to other relevant folder or how to download files in relevant folders other than download folder

    how to move downloaded files from download folder to other relevant folder or how to download files in relevant folders other than download folder

    Just drag the file from the Download folder to the folder of your choice in Finder. If you are using Safari you can designate a new default download destination in Safari>Preferences>General tab, 'Save Downloads to...'. Other browsers should have a similar option in their preferences.

  • TS1538 how to download files from laptop to ipad air

    how to download files from laptop to ipad air

    Sync them via iTunes as you would with any other iDevice.

  • I am using Mac OS X Lion 10.7.3 with Safari 5.1.5, to download files i use secondary click then followed by download linked file, now i am unable to download by that way previously i did. why?

    i am using Mac OS X Lion 10.7.3 with Safari 5.1.5, to download files i use secondary click then followed by download linked file, now i am unable to download by that way previously i did. why? please help me downloading files using that way

    What happens when you try?

  • How to access remote database using applet

    hi all,
    I want to know how to access remote database using applet,
    Please help me anybody.
    Regards
    Jesu

    If the database is on a public server, you probably can't access it directly (security wise). You can make your applet talk to a server-side application, which makes the database calls on behalf of the applet. But even in an intranet environment this setup is often preferable, because you don't need to distribute a JDBC driver to all your clients.

  • How can display svg file by using applet

    Hi ,
    my problem is ..
    1. I have one servlet which is generating svg file by using batik package.
    2.There is one Applet which receives SVG file from Servlet ..
    From here i dont have dont doubts.. then my doubt is
    3. How can display that svg file on the browser..
    please help me if u know any ,
    thanks regards,
    Balu

    Maybe this page can help you?
    http://www.w3c.org/Graphics/SVG/

  • Download and Upload using applet

    hi everyone,
    i tried to develop an applet that can handle upload and download file from server to client and vice versa.
    is there anyone can help me?
    Please help.
    thank you for replies.

    You need to sign your applet and the user needs to trust this signature in order for the
    applet to read from the local filesystem and or connect to a server other than the one the
    applet came from.
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post
    Here is some code that will upload (both msjvm and sun jre) but I never really finished
    it. Note that if you use the applet with msjvm the client has to adjust java security in IE
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    public class srvHead extends java.applet.Applet implements Runnable{
         String c = "";
         public srvHead(){
              new Thread(this).start();
         public void init(){
    //          new Thread(this).start();
         public void run(){
              try{
    // run this as an application first, when it works than make an applet of it
                   URL u = new URL("http://localhost:101/test");
                   URLConnection c = u.openConnection();
                   // post multipart data
                   c.setDoOutput(true);
                   c.setDoInput(true);
                   c.setUseCaches(false);
                   // set some request headers
                   c.setRequestProperty("Connection", "Keep-Alive");
    // TODO: get codebase of the this (the applet) to use for referer
                   c.setRequestProperty("HTTP_REFERER", "http://applet.getcodebase");
                   c.setRequestProperty("Content-Type", "multipart/form-data; boundary=****4353");
                   DataOutputStream dstream = new DataOutputStream(c.getOutputStream());
    // write content to the server, begin with the tag that says a content element is comming
                   dstream.writeBytes("--****4353\r\n");
    // discribe the content, (in this case it's a file)
                   dstream.writeBytes("Content-Disposition: form-data; name=\"myfile\"; filename=\"C:\\myFile.wav\"\r\nContent-Type: application/octet-stream\r\n\r\n");
    // open a file
                   String title = "Frame Title";
                   Frame frame = new Frame("Select a file");
                   FileDialog fd = new FileDialog(frame);
                   frame.setSize(400, 400);
                   fd.show();
                   System.out.println(fd.getDirectory() + fd.getFile());
                   File f = new File(fd.getDirectory() + fd.getFile());
                   FileInputStream fi = new FileInputStream(f);
    // keep reading 1000 bytes from the file
                   byte[] bt = new byte[1000];
                   int cnt = fi.read(bt);
                   while(cnt==bt.length){
                        dstream.write(bt,0,cnt);
                        cnt = fi.read(bt);
    // send the last bit to the server
                   dstream.write(bt,0,cnt);
    // now close the file and let the web server know this is the end of this form part
                   dstream.writeBytes("\r\n--****4353\r\n");
    // send a form part named TargetURL with the value: /IntranetContent/TelephoneGuide/Upload/
                   dstream.writeBytes("Content-Disposition: form-data; name=\"TargetURL\"\r\n\r\n");
                   dstream.writeBytes("/IntranetContent/TelephoneGuide/Upload/");
    // let the web server know this is the end of this form part
                   dstream.writeBytes("\r\n--****4353\r\n");
    // send a form part named redirectURL with the value: http://none/none
                   dstream.writeBytes("Content-Disposition: form-data; name=\"redirectURL\"\r\n\r\n");
                   dstream.writeBytes("http://none/none");
    // this is the last information part of the multi part request, close the request
    // close the multipart form request
                   dstream.writeBytes("\r\n--****4353--\r\n\r\n");
                   dstream.flush();
                   dstream.close();
                   fi.close();
                   try{
                        DataInputStream in =
                             new DataInputStream(
                                  new BufferedInputStream(c.getInputStream()));
                        String sIn = in.readLine();
                        boolean b = true;
    // TODO: this will loop forever unless you make sure your server page
    // sends a last line like "I am done"
    // than you can do wile(sIn.compareTo("I am done")!=0){
                        while(sIn!=null){
                             if(sIn!=null){
                                  System.out.println(sIn);
                             sIn = in.readLine();
                   }catch(Exception e){
                        e.printStackTrace();
              }catch(Exception e){
                   e.printStackTrace();
         public static void main(String[] args) {
                   new srvHead();
    }

  • How to download files from the internet??

    I am a new Mac user, and I am soooo befuddled by downloading files, and what to do with them once they are on the desktop/under devices in Finder. Would someone here be kind enough to explain how to do this, please, or show me in the forum where this is already covered? Thank you very much in advance.

    Hiya,
    Downloading files is simple. All downloads appear in a download window that will open up. Once they are downloaded, you can click the "clear" button if you wish - you don't need them in there any more, and close the window. Files will then be wherever they're set to download to in your Safari preferences - Desktop, Downloads folder etc - and can then be used as you wish, opened, edited, moved. You can drag the files from the desktop into folders in finder. Sadly, someone at Apple foolishly thinks having no "cut" option in finder as you do in windows was a good idea - not quite sure how they came to that conclusion - so you'll have to drag the files from one folder to another, or copy them and then delete the original.
    If you're downloading compressed files (.zip) you may want to look up "Stuffit Expander" - a great file extraction tool.
    Hope this was the information you're after.

  • ADF: how to download files?

    good day,
    does anyone know what the best way is to download a file to the client side using ADF? is this a trivial thing to do? i can find docs online on how to upload files using ADF but nothing for downloading files using ADF.
    initially, my thought was to use the FacesContext ResponseStream; but quickly realized that facesContext.getResponseStream returns a null with in my backend bean. so, i decided to bypass ADF and use HttpServletResponse's ServletOutputStream and simply write to this object. this works fine but ran into another problem, this comletely bypasses the ADF framework. after downloading the file ADF does not know what state it is in (i.e. my pages do not get updated). nothing gets updated via ADF.
    a second approach was to to kick off writing the Servlet OutputStream in a separate thread and have the backend bean return first. well... ran into another problem: java.lang.IllegalStateException: getOutputStream() has already been called!. obviously, i do not understand how the response mechanism works for servlets :-( it appears that per request the ouputstream can be only written to/flushed once.
    so if anyone has a way to correctly download a file using ADF please share.
    thank you

    Lius,
    thank you for the link. i read through it.
    for a existing file on the server a redirect works. but what if i do not have a physical file on the server and i simply want to write it from memory to the client side. i would like to write an outputstream object from the server directly to the user's browser.
    from the backend bean i do the following:
    ServletOutputStream out = response.getOutputStream();
    ByteArrayOutputStream outputStream = getOutputStream();
    // Reading the bytes through buffered input stream and writing the
    // presentation to the servlet output stream in the form of bytes
    // using
    // buffered output stream\
    while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
    bos.write(buff, 0, bytesRead);
    // Flushing the buffers of Http Response. this is bad for ADF.
    response.flushBuffer();
    and once i flush the buffer here it returns to the client and the user can than download the file but it completely bypasses the ADF framework and i am unable to make any ADF callbacks (i.e. send messages or use adf progress bar) :-(
    is there a way to download a file to an ouputstream without having it on the server side as a file.
    thanks for you help,
    joon

  • How to download files from Application Server of Unix o.s to local director

    Hi All,
    I am trying to download files from Apllication server of Unix operating Systems to local file in excel sheet format using a z-program.but whenever I am trying to use OPEN dataset ........
    it is showing sy-subrc = 8.
    Can I have any clew please.
    Thanks in advance,
    Regards,
    AMEER.

    Hi Sreekanth,
    Thanks a lot for quick reply.I have to download that files from z-program only. I am giving you my code below.
    *& Report  ZTRAK_DOWNLOAD                                         *
    REPORT  ZTRAK_DOWNLOAD  MESSAGE-ID ZCT                   .
    SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD WITH FRAME TITLE TEXT1.
      PARAMETERS :
           SERDIR LIKE RLGRAP-FILENAME DEFAULT '/usr/trak',
           LOCDIR LIKE RLGRAP-FILENAME DEFAULT 'C:\Trak'.
    SELECTION-SCREEN END OF BLOCK DOWNLOAD .
    SELECTION-SCREEN BEGIN OF BLOCK INFO2 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT2.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT3.
    SELECTION-SCREEN END OF BLOCK INFO2 .
    SELECTION-SCREEN BEGIN OF BLOCK INFO3 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT4.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT5.
            SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT6.
           SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT7.
           SELECTION-SCREEN SKIP 2.
           SELECTION-SCREEN COMMENT 1(79) TEXT8.
    SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT9.
    SELECTION-SCREEN END OF BLOCK INFO3.
    *- Internal Table to output data in Excel
    DATA: BEGIN OF tab_excel OCCURS 0,
            col1(50),
            col2(132),
            col3(255),
            col4(100),
            col5(100),
            col6(50),
            COL7(60),
            col8(30),
            col9(30),
            col10(30),
            col11(20),
            col12(15),
            col13(15),
          END OF tab_excel.
    DATA: FILE LIKE RLGRAP-FILENAME .
    DATA: W_DATASET(80).
    INITIALIZATION.
      TEXT1  = 'Download Reports'.
      TEXT2 = 'The Program downloads the reports generated by Trak'.
      TEXT3 = 'Utility from Server to Local PC.'.
      TEXT4 = 'Check the following before executing the Program.'.
      TEXT5 = '     1. A valid Server path is provided.'.
      TEXT6 = '     2. A valid Local PC path is provided.'.
      TEXT7 = '     3. Local PC has 10 MB free space.'.
      TEXT8 = 'The report can be executed in the forground.'.
    TEXT9 =
    'The report should be executed after execution of Transaction TRAK'.
    AT SELECTION-SCREEN.
    IF SERDIR EQ ''.
    MESSAGE E001(ZCT).
    ENDIF.
    IF LOCDIR EQ ''.
    MESSAGE E002(ZCT).
    ENDIF.
    START-OF-SELECTION.
    Download ABAP Development Summary Report
    FILE =  '\ABAP_Report_Developments.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAP_Report_Developments.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download BDC Development Report
    FILE =  '\BDC_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/BDC_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Development Summary Report
    FILE = '\Developments_Summary_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Developments_Summary_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Enhancement Development Report
    FILE =  '\Enhancement_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Enhancement_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download field exit Development Report
    FILE =  '\Field_Exit_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Field_Exit_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Frequency & Purpose Report
    FILE =  '\Frequency_And_Purpose_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Frequency_And_Purpose_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Group Developments Report
    FILE =  '\FunctionGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Module Developments Report
    FILE = '\FunctionModule_Developments_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionModule_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    FILE =  '\Include_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Include_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download UserGroup Developments Report
    FILE =  '\UserGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Modified_Standard_SAP_Objects_Report
    FILE = '\Modified_Standard_SAP_Objects_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Modified_Standard_SAP_Objects_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    *FILE =  '\Include_Developments_Report.XLS'.
    *CONCATENATE LOCDIR FILE INTO FILE.
    *W_DATASET = '/Include_Developments_Report.dat'.
    *CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    *PERFORM INIT.
    Download SAP Script Developments Report
    FILE =  '\SAP_Scipt_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/SAP_Scipt_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Transaction Developments Report
    FILE =  '\Transaction_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Transaction_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download User Exits Developments Report
    FILE =  '\UserExits_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserExits_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download ABAP Query Developments Report
    FILE =  '\ABAPQuery_Developments_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAPQuery_Developments_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Functional Area Developments Report
    FILE =  '\FunctionalArea_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionalArea_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    MESSAGE S003(ZCT) WITH LOCDIR.
    END-OF-SELECTION.
    This routine checks whether file exists if yes downloads it to
    the Local PC
    FORM INIT.
    OPEN DATASET W_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
       IF SY-SUBRC <> 0.
          EXIT.
       ENDIF.
       READ DATASET W_DATASET INTO  tab_excel.
       APPEND tab_excel.
       CLEAR tab_excel.
    ENDDO.
         PERFORM DOWNLOAD_FILE.
    ENDFORM.
    This routine downloads the data in an XL format on local PC
    FORM Download_File .
      CALL FUNCTION 'WS_DOWNLOAD'
                EXPORTING
                     FILENAME                = FILE
                     FILETYPE                = 'DAT'
                TABLES
                     DATA_TAB                = tab_excel
                EXCEPTIONS
                     FILE_OPEN_ERROR         = 1
                     FILE_WRITE_ERROR        = 2
                     INVALID_FILESIZE        = 3
                     INVALID_TYPE            = 4
                     NO_BATCH                = 5
                     UNKNOWN_ERROR           = 6
                     INVALID_TABLE_WIDTH     = 7
                     GUI_REFUSE_FILETRANSFER = 8
                     CUSTOMER_ERROR          = 9
                     OTHERS                  = 10.
        IF sy-subrc <> 0.
         message ''.       " Error in file transfer
        ELSE.
          CLEAR TAB_EXCEL.
          REFRESH TAB_EXCEL.
          FILE = ''.
          W_DATASET = ''.
        ENDIF.
    ENDFORM.
    I have created those files in Application Server running in another z-program in background mode.Then I am trying to download those files using above the program.I am creating those trak/Trak files manually and I can able to see those files in A.S level.But when downloading the same files I am facing the problem.
    regards,
    Ameer

  • How to download  file with Save As dialog

    I am trying to download files with a Save As dialog, according to Jason Hunter's instructions in Jave Enterprise Best Practices.
    String filename = "content.txt";
    // set the headers
    res.setContentType( "application/x-download" );
    res.setHeader( "Content-Disposition", "attachment; filename=" + filename);
    // send the file
    OutputStream out = res.getOutputStream();
    returnFile( filename, out);
    The file content.txt is in the root directory of my webapp. But I get this stack:
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.FileNotFoundException: content.txt (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.(FileInputStream.java:64)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.returnFile(FileDownloadServlet.java:43)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.doGet(FileDownloadServlet.java:24)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:484)

    The root of the webservers changes from server to server and
    sometimes it depends on the path you run webserver exe.
    The best i have found to overcome this kind of problems is by
    using getResourceAstream() method which basically looks at classpath locations only, but still this has some problems like it should kept at the
    specified classpath becoz the getResourceAsStrem() method is not static
    method and it always associated with the class object and the file
    accessing also should be in the same package/classpath.
    by using getResourceastream you cannot look at other places (except classpaths)
    and this should be used only if you looking for .properites definitions.
    the Second best method is
    see you have a file called "context.txt" right
    before you create a file, first create a directory at the root, let say
    "\tmp"
    and then create a file \tmp\context.txt
    and then open an output stream to it either using fileoutputstreamm...
    and then write all output content to servlet/client output stream.
    this will be the best becoz you are specifying the "\" the root
    and this is common for all operating systems and definitely it will create at the root directory either serverroot or harddiskdrives root
    so you will never missout and the exceptin will also not comes along the way
    cheers..
    if you get new thing , let me know
    bye
    with regards
    Lokesh T.C

  • How to download file from server to client's local ??

    How to download a file from the server to the client's local machine in a particular folder without users intervention ie. 'Save As" prompt of the browser should be avoided and if the client clicks on "Download" button, the file should get automaticaly downloaded to say, "c:/reports/' on his/her local machine. This is for Java based web appliaction.

    http://jguru.com/faq/view.jsp?EID=10646

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog}
    i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
    response.setHeader("Pragma", "public");
    response.setHeader("Cache-Control", "no-cache");
    *** download file
    if((trans !=null)&&(trans.equals("download")) )
    response.setContentType ("application/x-download");
    response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
    %>
    <script>
    window.location.href=<%=gallerypath+fileName%>';
    </script>
    <%
    trans="";
    //System.out.print("download : "+fileName );
    //***************************************

    Can you try below code, It should work...
    <%
    String myFileName = request.getParameter("fileName");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
    String root = "D:/";
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    try {
    in = new BufferedInputStream
    (new FileInputStream(root + myFileName));
    int ch;
    while ((ch = in.read()) != -1) {
    outs.print((char) ch);
    finally {
    if (in != null) in.close(); // very important
    outs.flush();
    outs.close();
    in.close();
    %>

Maybe you are looking for

  • Ref cursor trouble

    Hi All, My requirement is to fetch values from any given tables through ref cursor, so i have used a below procedure CREATE OR REPLACE PROCEDURE et1(     tab_name IN VARCHAR2,     c1 OUT sys_refcursor) AS   v_prim_val VARCHAR2(2000);   v_sql      VAR

  • Boolean Logic Issue

    I have 2 sensors in a system. Items pass these sensors. First is an inductive sensor and only activated by a passing metal object, which is what we want. Second is an IR Through Beam - if the Inductive sensor activates it means a metal object has pas

  • I have a HP Pavilion which has a touch sound bar above the keyboard. The display is no longer there

    HP Pavilion Entertainment PC  Windows 7 Wich has a touch sound bar above the keyboard and a display shows on the bottom of the screen when I touch the bar. This display is not there any longer. This question was solved. View Solution.

  • Query Jump from Bex Analyzer to r/3 transactions: error of web server

    Hello, I have created a query jump in the RSBBS transaction to go in R/3 through a Bex Query. When i choose the jump in the query anayzer I have the error message: <b>No Web server maintained for the presentation of log. system.</b> Do you have ever

  • Very urgent Issue - Convert the hours into Minutes

    Hello Guys, I have an infoobject zkabc, which is having hour information. eg: 24.588, which means 24 hrs and 30 min (..588 hrs). I want to display the infoobject value from 24.588 to 24.30 (24 hrs 30 minutes) is it possible in BEx. Issue critical. Th