Servlet Download File (XLS, PDF, DOC)

When the user clicks the link to download a file, the Open/Save/Cancel dialog box pops up twice.
Here are the headers I am setting:
response.setContentType(getContentType(sFiletype));
response.setContentLength((int) file.length());
response.setHeader ("Content-Disposition", "attachment; filename=\"" + sFilename + "\"");
response.setHeader ("Pragma", "public");
Note: getContentType(sFiletype)returns the appropriate MIME type for the file extension provided.

Your code is unreadable and like garbage. In the future please post well formed code in code blocks.
At least you can give the following FileServlet example a try: http://balusc.blogspot.com/2007/07/fileservlet.html

Similar Messages

  • How to display.xls, pdf, .doc files in UIImageView within a UIScrollView.

    Hi,
    I am new to iPhone programming. I need some help.
    I want to display .xls, pdf, .doc files in UIImageView within a UIScrollView programtically how can i do this. What is the procedure.
    Pls. provide me a sample application.
    If anyone knows pls. respond it would be of great help for me.
    Thanks in Advance,
    Regards,
    Sreelatha.

    Hi Sreelatha. The best example code for your purpose is the Scrolling sample app I referred to previously. The word Scrolling in that post is a link to the download page. I think that code will answer all your questions about how to init a UIImage, then use it to init a UIImageView, and then position the UIImageView frame in a UIScrollView. Two cases are demostrated: 1) Scrolling horizontally through a series of images; 2) Scrolling both H & V over a single image which is several times larger than the window.
    You might also be interested in the PageControl sample app in case you want to add a page control to your scroll view.
    Reading your last post again... I sure hope we've been discussing images (like jpegs?) in this thread. This isn't about reading and rendering the actual xls, pdf and doc files, is it?? Of course the iPhone handles html beautifully, so for example, an html representation of a doc file would play nicely. But in that case you'd want a UIWebView, not a UIImageView.

  • How do one can upload a file (a PDF, doc etc) while filling a web form through chrome or safari? It is possible to upload a photo from the camera role, but other file types can not be uploaded.

    How do one can upload a file (a PDF, doc etc) while filling a web form through chrome or safari? It is possible to upload a photo from the camera role, but other file types can not be uploaded.

    For a variety of reasons, mostly related to security, the iOS operating system limits what can be done with respect to file uploading and downloading. But whenever you encounter a limitation like this always think, "There must be an app for this."
    Check the apps James Ward suggests.

  • I can download and view PDF docs on my MAC but can not save or print them - Help !

    I can download and view PDF docs on my MAC but can not save or print them - Help !

  • Unable to download/save a pdf doc from Adobe Acrobat Reader (in IE8 or IE9)

    I can open the pdf doc, but the button that I would normally click to download the doc to my computer is not highlighted.  I tried upgrading from IE8 to IE9, but still cannot download.  Thanks for any help!

    Actually, I had similar issue, but it was FM.  Occasionally, when I did a Save as PDF or Save as with HTML, FM went on for a few moment then stoped saving with an error message along the line: Cannot create <some file name>...  It kept doing the same thing for several tries until I deleted the previously generated files, then all would be well for a while, until the next time...  I don't know it had anything to do with the generated files (PDF or HTML) being opened on a web-browser at the moment.  Yet, as I remembered prior to that and verified afterward, in those times that went without such error, those files were being opened as well.  Thanks!
    PS: I'm using FrameMaker 11

  • Open embedded files in PDF doc

    When I convert a word file with embedded files (insert object) then convert the document to PDF i cannot open the embedded files they just show up as pictures. Where is the setting to enable me to click on the file in PDF and have it open. I have Pro 8.1.4

    Not that I know however a person I was working with just sent me a file
    that I cannot share but all embedded files were click to open within
    Carlo De Luca | Avaya Operations Support | Senior Proposal Manager |
    Virtual Office - Las Cruces, NM 88007 | Voice/Fax +1 908.953.5755 |
    [email protected]
    Click here to access RFP Q&A Database Search
    Click here to access Avaya ProposALL Wizard for BusinessPartners
    Click here to access Avaya ProposALL Wizard for Associates
    Please consider the environment before printing this email
    This e-mail message is for the sole use of the intended recipient(s) and
    may contain confidential and/or privileged information. Any unauthorized
    review, use, disclosure, or distribution is prohibited. If you are not
    the intended recipient, please contact the sender by reply e-mail and
    destroy all copies of the original message.

  • Can't download files in PDF

    I have adobe XI already installed on my computer, but I am unable to open any files in PDF. What's wrong?

    We can't know. You are not providing any system information or other details like waht PDFs you are trying to open for instance.
    Mylenium

  • Script for downloading files from pdf placed on web, script for printing for exchange-

    Looking for java script command to set on button in pdf. We have mp3 and pdfs on our web site, example of URL: http://www.uzlicek.cz/download/Pohadky/O_holcicce_ktera_si_prala_byt_dospela.mp3
    By clicking on button/link in reader I would like to appear a dialog box with offer to Safe file as…
    Any suggestion? In case of using “link tool” the file starts downloading to cache and this is not the objective. In case of using “sound tool”, the file does not appear for saving.
    For exchange the script for Print the current page:
       var n = this.pageNum;
        var pp = this.getPrintParams();
        //pp.pageSubset = pp.subsets.all;
        //pp.printContent = pp.constants.printContent.doc;
        pp.firstPage = n;
        pp.lastPage = n;
        this.print(pp);
    Cheers Martin

    It can't be done using only a PDF file - any link to a URL will simply open your web browser, and whatever handler that browser uses when presented with MP3 files will be triggered (download, play, etc.) - nothing in the PDF can override that handler and force a "save" operation.
    Instead you'll need to configure your website to force downloads (using HTTP headers) and link to those URLs instead; which is a subject outside this forum.

  • Download CSV/XLS/PDF Error

    Hi Folks,
    When I go to download a report in xls or pdf format, I get an error. I am told firstly, in the PDF case:
    Adobe Reader could not open 'customers.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
    and in the XLS case
    The file you are trying to open, 'customers2s.xls', is in a different format than specified by the file extention. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
    In the PDF case, I open the file and see nothing. In the XLS case, I open the file and see
    "ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    and a line of links from the footer, including 'Home" "Application 1----", "Edit Page 1", "Create" "Session" "Activity" "Debug" "Hide edit links" etc.
    However, on some other pages I do print out the reports (which have fewer columns) and I get nice reports in the xls case, but weird results in the pdf case (oddly shaped short and wide pages that are all blank - with a 1:8 ratio in the number of pages:number of records in teh original report).
    Does anyone know what might be causing my problem(s)? Throughout all my reports, both the fully problematic and less problematic ones, I have 850 records.
    Edited by: user10225290 on Jan 29, 2009 2:31 PM

    If you don't install either FOP or BI Publisher (or add-on libraries PL/PDF), than you {color:#ff0000}CAN NOT{color} print PDF style files with APEX..
    (Check out this link to see how to accomplish setting up BI Publisher and/or FOP and the integration with APEX)
    Thank you,
    Tony Miller
    Webster, TX
    "Understanding is a three edged sword. Your side, their side, and the truth" - Kosh Naranek

  • Links to mp3 files in pdf docs not working on laptops

    I'm working in IDCS3 on imac OS 10.4.11, producing pdf documents with links to sound files (mp3) and video (mp4). The sound/video files are not embedded.
    The pdfs and sound/video files are placed on a CD. We have tested these pdfs on desktop Macs and desktop PCs, and the links to the sound files work fine, but on a laptop the links to the sound files fail completely (ie usually nothing happens, though sometimes there is a message saying the computer is searching on the C drive for the files, instead of in the correct folder on the disk). The links to the video files do work though. Any ideas?

    I have tried to embed the mp3 and mp4 files, but the place command will not recognise them (they are always greyed). The only way I have been able to make the sound files play is by linking to the files using a button, but the 'embed all' command on making a pdf doesn't seem to work with this.

  • I can´t open downloaded files ending .pdf.part? Why do I suddenly get this problem?

    When I open them in Word they are blank och in Adobe they don´t open at all.
    I havent changed anything exept accepted updates
    When I Downlode from Websites, this simply happens, never ever happend before. Started in February

    "Next" time it will be easy.
    But the 1st time, "Ya Just Gotta Know", and that is not so easy. 
    Glad it got you going.

  • Firefox downloads file as .ASPX instead of .PDF

    Trying to download Monthly Statements from Merrill Lynch website. Firefox used to download them as .PDFs (and MS IE 8 still does). Now Firefox downloads an .ASPX instead. Or maybe not -- If I change the extension of the downloaded file to .PDF. it loads correctly in Acrobat Reader. Why does Firefox use the wrong extension??
    == This happened ==
    Every time Firefox opened
    == About a month ago (???)

    Try "Reset Download Actions": http://kb.mozillazine.org/File_types_and_download_actions

  • Printing downloaded file

    I am not able to print a downloaded file, Adobe PDF.  The print queue says it is sending data to the printer but nothing prints.
    k

    doebiek wrote:
    I have opened the file, I can read it on the monitor.
    What program did you opened and read the pdf file in.
    Does it not have a File > Print drop down menu...?

  • Cannot download .pdf files and word docs from KM using Web Dynpro

    Dear Portal Gurus,
    Using KM API, I am trying to download, documents from KM in my Web Dynpro Application. But .pdf files and word docs with screenshots are not getting retrieved from KM. Word docs opens with no content and Adobe opens with an error saying "Either it is a damaged file or It is not a supported file".
    I am using the following KM service to download the content.
    public byte[] retrieveResourceInBytes(String strRid){                    
    /////  after a few lines  ////
         if (this.loggedOnUser.isAuthenticated()) {
    // create a resource context with the authenticated user
         rContext = new ResourceContext(this.loggedOnUser);
    // create a RID to handle a resource
          aRid = RID.getRID(strRid);
              try {
              // get an instance of a resource factory
                     final IResourceFactory aResourceFactory = ResourceFactory.getInstance();
    // retrieve a folder/file  with context
                                                 aResource =  aResourceFactory.getResource(aRid, rContext);
         if(aResource.isCollection()) {
                                                                      aResource = (ICollection) aResource;
                                                      IPropertyMap objIPropertyMap = aResource.getProperties();               
                                                 IMutablePropertyMap objIMutablePropertyMap =objIPropertyMap.getMutable();
                                                 objHashMap = new HashMap();
         if (aResource != null) {
                                                                         IContent oldContent = aResource.getContent();
                            InputStream objInputStream=oldContent.getInputStream();
                 byte[] theBytes = new byte[objInputStream.available()];
                 objInputStream.read(theBytes);
                        return theBytes;
         } //  catches all the exceptions here///
    Could you please advise if I am doing something wrong else could you please advise me for any corrections which would help?
    Thanks a lot in advance,
    Zeena
    Edited by: Zeena Ali on Mar 25, 2009 8:13 AM

    On Apr 10, 2013, at 4:10 PM, AdityaKalania wrote: Replies in RED below:
    Re: Cannot download pdf files from web sites
    created by AdityaKalania in Adobe Reader - View the full discussion
    Hi,
    Which web browser are you using to view the PDF? Safari 5.1.8
    When you open the PDF in Adobe Reader add-in you will either see a floating toolbar
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-5224223-317859/430-90/floating +toolbar.JPG
    or a normal toolbar
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-5224223-317860/450-11/normalto olbar.JPG
    both the toolbars have save button, use the button to save the file locally. I do not see these toolbars. I do, however see this
    and it works! Thanks
    Hope this will help you.
    Thanks
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5224223#5224223
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5224223#5224223
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5224223#5224223. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe Reader by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Read files with no app suffixes (.pdf, .doc. xls, etc ...)

    Hi,
    On a Macintosh, files do not have suffixes (.pdf, .xls or .doc, etc ...) to identify the application that created the file. How can I open a file on my iPhone if there is no suffixes ?
    Thanks in advance.

    You're welcome.
    The files on your Mac include the file extension, which you can choose to show or not show with the files on your Mac.
    Since I don't email files to Mac users only, I'm in the habit of including the file extension with all email attachments.
    I'm not aware of a way to force open a file with the iPhone.

Maybe you are looking for

  • How do I get my subscription activation to "stick"?  30 days in and it is not working now???

    I signed up for the Creative Cloud on November 25th.  Everything went fine, I installed various software without any (known) issues and things worked...  On, or around, Saturday, Dec. 22, I got a "subscription activation" notification and I went thro

  • Does EDQ support MINUS set operation

    Hi I would like to implement a MINUS set operation using EDQ - is this possible in EDQ? For example, I have duplicate records in my input set and I can use the group and merge processor to generate the unique records (btw, it selects the lowest id of

  • Does a network published shared variable drop the waveform attributes?

    I have the analog input source for a waveform on one NI chassis. The trigger to begin the trend is on another NI chassis. Both of them feed data to a remote Windoze host. I would like to know how I can pass the waveform attributes, ie. Plot Names fro

  • Having Trouble Opening Catalog

    I recently subscribed to the Adobe Creative Cloud.  When the new LightRoom CC was announced, I upgraded to that from my older LR 4.  Now I am having trouble opening the LR Catalog.  The box that pops up says it is note writable and cannot be opened. 

  • Accept license agreement again?? It's making me lose data.

    In Acrobat XI, I had several files open, filling out forms. Acrobat crashed, reopened, and asked if I wanted to recover the data I had already filled in. I did. Then, before it opened my documents, Adobe asked me if I would accept the license agreeme