Post a file?

I have a servlet that processes incoming files (chosen using the filechooser on a form). I'd like to be able to create a new file, either in a jsp or servlet, and pass it to this servlet.
How do I pass files over to the servlet without using a form (for example, I want to pass over a File object). And how do I parse the request at the other end--can I use a diskfileupload just the same way I use for a form?
Thanks.

Sorry if this code isn't complete and/or perfectly setup for you, i just cut & pasted it, but you get the point, hope this helps (it works for me):
            FileInputStream istr = null;
            OutputStream ostr = null;
            response.setContentType("application/binary");
            response.setHeader(
                "Content-Disposition",
                "attachment; filename=\"" + file.getName() + "\";");
            try {
                istr = new FileInputStream(file);
                ostr = response.getOutputStream();
                int curByte = -1;
                while ((curByte = istr.read()) != -1) {
                    ostr.write(curByte);
                ostr.flush();
            catch (Exception ex) {
                throw ex;
            }

Similar Messages

  • How to Print Post Script Files

    Hi All,
    I am trying to make a utility software in foxpro that could print post script file on:-
    1) Post script printer
    2) Non Post Script printer
    Operating System Windows 95 & above
    Help is requested from all the community members
    Reagards
    Harsh

    PostScript printer - send it to the printer port e.g. LPT1: with a simple copy.
    Non-PostScript printer - you'll need to buy a PostScript RIP, or perhaps use Acrobat Distiller to convert the PostScript to PDF, then print the PDF with Acrobat's API - see the Acrobat SDK. (This is not possible with the free Reader).

  • Error while posting xml file to URL using URLConnection

    Hello everyone,
    I am facing an issue from long time related to URLConnection. If this would be resolved by your help then I would be very grateful to you.
    One application which posts xml file to URL hangs and after waiting for 5 mins it throws 504 error:
    java.io.IOException: Server returned HTTP response code: 504 for URL: http:hostname.
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:715)
    Same application is running fine without error on another environment from last 5 years. But on another env it is erroring out from the day 1.
    We have many workarounds in place none worked.
    I tried to use HttpClient from apache but that too hanged at URLConnection.getInputStream() method call.
    App is running on iPlanet web server 6.1 using JDK 1.4.0_03
    We still dont know why this program hangs at that particular line in only one env but many times it runs fine. That means 30% of the times it posts xml file without error but 70% times it errors out. So our program logic is to retry until post is successful.
    Once this issue is resolved we will remove the logic of trying again and agian.
    Please provide inputs.
    Thanks,
    Nitin

    The HTTP response 504 means that the server, acting as a gateway, has not received a response from an upstream server in the time it expected.
    I think this is problem is due to the remote server that receives the XML and takes too long to return a response to the local application that posted the XML.
    Try HttpClient and set the timeout variable of the HttpClient instance used.
    Here http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java?revision=480424&view=markup
    a Post XML sample.
    NB: HttpClient > setTimeout method is deprecated. See : http://jakarta.apache.org/commons/httpclient/apidocs/index.html for an alternative
    Hope That Helps

  • Error while posting .ZIP file

    Hi All,
    I am working on file to file scenario.. I want to post .zip file from source to target. I am not using any mapping for this... I m using the Integrated configuration for theis scenario.. We are using sFTP advantco adapter for both sender and receiver.
    I am able to post the .zip file with size 50KB only.
    If i send .zip file with more than 50KB size, sender channel picked the file but i am getting the below error in the receiver communication channel.
    Error: Cannot write content to remote file XXXX: Possible causes: SFTP connection is broken or remote file/directory is in use: java.lang.ArrayIndexOutOfBoundsException:  (Software version: 3.0.17)
    How to transfer .zip files with more than 50KB size.
    Thanks,
    Soumya.

    Hi Soumya,
    I see no reason to use sFTP or  advantco for this.
    you can config this scenario using PI regular File adapter, and PI regular File to File scenario.
    in your case you just create an empty DT without fields in Repository, you need to create interfaces (OB,IB) for the Configuration
    this works for me in many scenarios.

  • Error posting the file

    Since upgrading to 10.10.1 (14B25) on my iMac a couple of days ago I get the following error when I try to insert an image in an email -
    Error posting the file to https://thegallerykinsale.com/ckfinder/core/connector/php/connector.php?command= QuickUpload&type=Images&CKEditor=editor1&CKEditorFuncNum=2&langCode=en
    This does not happen on my Macbook pro which has OS X 10.10 installed and thing work fine on my iPad, so I suspect this is to do with the upgrade.
    Any help much appreciated.
    Regards, Kenneth.

    Since upgrading to 10.10.1 (14B25) on my iMac a couple of days ago I get the following error when I try to insert an image in an email -
    Error posting the file to https://thegallerykinsale.com/ckfinder/core/connector/php/connector.php?command= QuickUpload&type=Images&CKEditor=editor1&CKEditorFuncNum=2&langCode=en
    This does not happen on my Macbook pro which has OS X 10.10 installed and thing work fine on my iPad, so I suspect this is to do with the upgrade.
    Any help much appreciated.
    Regards, Kenneth.

  • Post Processing file

    I am reading file in labview which contains some comments separated by backslash but i dont want those commensts to be dispalyed after reading to be displayed in indicator. How to do this.
    Below is attached vi and file
    Solved!
    Go to Solution.
    Attachments:
    post processing file.vi ‏8 KB
    qwerty.txt ‏1 KB

    I tried this match pattern also, with this i am facing two problems first, it is detecting only for one time whereas in my file i am having multiple comments, and it is detecting only the first comment it sees and second issue is that it is just separating the backslash from the string and i want to separate the whole string with backslash. May be i am not using it properly 
    below is the snippet of how i am doing.
    Attachments:
    read from file fp.png ‏219 KB
    readfromfilebd.png ‏31 KB

  • Converting Back to Original PDF Using Post Script File

    Is there any way to convert back to an original PDF using a post srcipt file that was created from that original PDF?  Allow me to fully explain my situation:
    I converted multiple pdf's that I created into a post script file.  I then utilized Adobe Distiller to convert them into a pdf that could be used for better printing and better usability by the end user.  Unfortunately, when Distiller did this conversion, it replaced my original pdf with the new one.  By the time I realized what was happening, all files had been replaced.
    I still have the post script file that was created from the original PDF file; is there any way possible using this post script file that it can be somehow converted back to the original PDF file?  There are some edits that I need to do on the original PDF.  The pdf that Distiller creates doesn't allow for anymore edits.  My goal is to be able to make my edits without having to re-create 37 pages of documents. 
    The software versions I'm using are as follows: Adobe Acrobat X Version 10.1.4, Adobe Distiller Version 10.1.438.
    If anyone has any ideas, please let me know!

    Hello, thank you for responding.
    Yes the url links start with http:
    For example when I type in
    http://canberracontemporaryartspace.wordpress.com/2013/07/06/staying-out-of-trouble/
    in the word document and click on it, the link works; but when I save it as a pdf it says "not found"
    And then when I type in
    http://www.camberwellspecialists.com.au/what-is-skin-cancer.html
    in the word document and click on it, the link works; but when I save it as a pdf it says "page not found"

  • Unable to create post script file in framemaker.

              I installed TCS 4.0 licensed suite. Due to some reason I need to delete Adobe PDF from Devices and Printers. Since then I am unable to create post script file using framemaker. I have tried uninstalling and installing TCS 4.0 again, but all in vain. What should I do now?

    If you delete critical parts of Acrobat there will be problems. Try doing a REPAIR of Acrobat Pro (from the Programs Control Panel), maybe it can undo the damage.

  • Post a File to a web server using HTTP_POST

    Hello,
    I have to generate a program to post a file ".TXT" to a web server using a HTTP POST with multipart form and a couple of variables (user, password).
    I was investigating and I found that I can do it using SAPHTTP but I dont know how to work with the FM HTTP_POST.
    Does anyone have a sample code?
    Thanks
    Ariel

    sample usage:
      CALL FUNCTION 'HTTP_POST'
        EXPORTING
          ABSOLUTE_URI                = IM_OFX_CONTROL_DATA-ADDRESS
          REQUEST_ENTITY_BODY_LENGTH  = RESPONSE_ENTITY_BODY_LENGTH
          RFC_DESTINATION             = IM_OFX_CONTROL_DATA-HTTP_RFCDEST
          USER                        = IM_OFX_CONTROL_DATA-HTTP_USER
          PASSWORD                    = IM_OFX_CONTROL_DATA-HTTP_PASSWORD
          BLANKSTOCRLF                = 'X'
        IMPORTING
          STATUS_CODE                 = STATUS
          STATUS_TEXT                 = STATUS_TEXT
          RESPONSE_ENTITY_BODY_LENGTH = RLENGTH
        TABLES
          REQUEST_ENTITY_BODY         = LT_REQUEST
          RESPONSE_ENTITY_BODY        = RESPONSE
          RESPONSE_HEADERS            = LT_RESPONSE_HEADERS
          REQUEST_HEADERS             = LT_HTTP_HEADERS
       EXCEPTIONS
            OTHERS                      = 1.
    Refer the programs:
    LFPIFF02            
    LOFXALSU04          
    LPRGN_URL_RESPONSEU01
    LSBCCU01            
    LSFTPU09            
    for some idea.
    regards,
    ravi

  • SapScript output spool to a POST script file

    We generate  billing invoice output using custom
    program/Sap script. Subsequently we release the invoice print out from
    the print spool to create a post script file from the print spool by configuring command set "G" in
    transaction u201CSPADu201D. This processis  is working fine in R/3
    However, when we migrated the same functionality to ECC, we are finding
    that the file created containing only garbage data.
    Anyone has encountered this issue and have suggestions to resolve this.
    Thanks
    Palani

    Hi Gary
    How the issue is resolved, please let me know. Since i am also facing same issue.
    Thanks
    M G Shankar

  • I am getting some errors while distilling the post script file.

    I am getting some errors while distilling the post script file. please check and suggest me, how to control this?
    <PDFX ISO="15930-1:2001" COMPLIANT="true">
    PDF/X Compliance Report
    1.  Summary
       Warnings: The total found in this document was 0.
       Violations: The total found in this document was 0.
       No problems were found in the document.
       This document passes PDF/X-1a:2001 compliance checks.
    </PDFX>
    Regards,
    Jack

    @Jack – you were using a joboptions file by Distiller to convert a PostScript file to a PDF/X-1a.
    What you get is no error message, just a report, that everything went ok. And in this case I cannot see any advantage using PDF Export for printing to PostScript/distilling to PDF. Ok, maybe one, CS5 and above would export in a background process.
    To prevent InDesign flattening transparency, you could use PDF/X-4 as your export setting. You cannot use writing to PostScript for that task.
    Check including tags for tagged export to prevent misalignment of text because of a strange bug with PDF Export when you are using 9pt text on 12pt leading or text with a ratio of 9/12 for point size and leading in multicolumn text frames.
    Uwe

  • How to configure a scenario which posts same file to different directories

    How to configure a scenario which posts same file to different directories of a receiving system?
    Consider an Idoc to file scenario where I have to post same file to two different directories but logical receiver system has to be same.

    Hi,
    You can try out like this: Using multiple receiver interfaces you can send it to multiple directories with the help of enhanced interface determination/conditions and with the help of multiple receiver communication channels.
    Another option is to copy the file from one target directory into another directory  with the help of Unix script by executing the same from the OS command level.
    One more option is to create a Java Server Proxy and inside the proxy, you can write java code to FTP into different locations.
    Hope this helps,
    Regards,
    Moorthy

  • How can I rip a 10" x 10" post script file from InDesign 6, it keeps telling me "the active document

    How can I rip a 10" x 10" post script file from InDesign 6, it keeps telling me "the active document uses multiple pages sizes and won't print.  My page sizes are all 10" x 10"

    Please post in the InDesign forums here http://forums.adobe.com/community/indesign/indesign_general. They will be able to help you.

  • Reading post script files

    Does Adobe offer a program that reads post script files?

    Adobe Acrobat can convert Postscript to PDF and display the PDF.

  • Posting sound files

    I just noticed that while no audio formats are supported in the "Attach Files" box, we can post various image formats, video formats (.mov and .swf), and text.
    So, to post audio, one could upload a bitmap of a sound file for importing into Audition; a video containing the audio; or raw audio data as a .txt file.  Using a text format might require converting binary audio data to hex which looks like a normal text file, depending on how the server handles text files.

    Alternatively, you could go to AudioMasters where we actively support Audition and actually let you upload audio files, believe it or not...
    Adobe might support Audition, but the people who run the forums clearly don't support the audio end users, do they? Otherwise perhaps they might not have gotten rid of all the FAQs, and actually let people post relevant files.

  • Exctract data from Post Script file

    Hi all;
    I need to extract, manipulate some data from post script file send them to database.
    How can i do that process?

    OT: Hey Rene, I see you've become a local celebrity
    around here!I'm still waiting for the groupies to show up, though. No luck so far. :p
    I think it's a nice initiative and
    enjoyed reading the interview.
    ; )Thanks. :)

Maybe you are looking for

  • Phone not starting on it's own - solution :)

    A week or so ago, I was trying to find out why my new phone (not jailbroken or second-hand) would no longer boot up on it's own and had to be connected to the computer to get started. I was given some useful tips including how to do a complete restor

  • ALV using Classes.

    hi all, How to create a ALV report using Classes....? any links or feedback will be appreciated. Thanks in Advance.

  • Need buttons on base movie to become inactive when external movie loaded

    Hi, I am working on a portfolio website and I have all my navigation with buttons linking to other pages, on the base level. All the buttons are  scattered around the stage and when one of these buttons is clicked an external movie is loaded in the c

  • Setting the "Email" Button to only send specific pages in a PDF

    Hey everyone, couldn't find this question on the board, so figured I'd give it a shot. I have a PDF I'm making w/a coverpage, what I'm trying to find out is if I can set the "email PDF" button to specifically send the PDF without the coverpage includ

  • Increase the data access time in custom development scenarios,layouts etc.

    Hello All, We have developed some custom scenario come interface for our Man-hours planning and actual posting. We have also included some validation in them from time to time. Now, it has started taking much processing time during data entry as well