Stream a pdf file But want it to open in the browser automatically.

Hi all,
I have successfully stream a pdf file to the browser. But it ask the user to save the pdf. This is not what i intended to do. I would like the browser to automatically load the pdf file.
How could i do that?
I already added the setContentType to "application/pdf".
Following is portion of my code:
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(preprintedForm);
          JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport, paramMap ,new JREmptyDataSource());
          response.setContentType("application/pdf");
          response.setHeader("Content-Disposition","attachment; filename=test.pdf");
          JRPdfExporter exporter = new JRPdfExporter();
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
          OutputStream ouputStream = response.getOutputStream();
          exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
          try
                                 exporter.exportReport();
                            catch (JRException e)
                                 throw new ServletException(e);
                            finally
                                 if (ouputStream != null)
                                      try
                                           ouputStream.close();
                                      catch (IOException ex)
                            }Thanks in advance.

Hi,
Try this
response.setHeader("Content-Disposition","inline; filename=test.pdf");
and from the Jsp or HTML from where you are trying to access this use. window.location.href.
Thanks and Regards,
Harsha

Similar Messages

  • Hi there I have updated to your lates version but every time I open up the browser and new windows I get this error message 'TypeError: Components.classes[cid] is undefined' although it does work but the message is very annoying

    Question
    Hi there I have updated to your lates version but every time I open up the browser and new windows I get this error message 'TypeError: Components.classes[cid] is undefined' although it does work but the message is very annoying

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • I can view a completed PDF file, but I can not open it

    I can view a completed PDF file in "view pane"  however when I open the saved file, it is blank.

    Try if updating to the latest version 10.1.3 still does the same.
    If it does, please tell me your display adapter, device driver version & date; see http://forums.adobe.com/thread/945765

  • PDF Files on desktop won;t open all the way. 11.07 won't download with Maverick 11.06

    I have Maverick 11.0.6.  It quit downloading 11.07 half way through.  Also, some PDF files on my desktop won;t open all the way.  Still show the logo. What is going on?

    The Installer that you had downloaded from http://www.adobe.com/support/downloads/detail.jsp?ftpID=5786 is the 11.0.07 patch update for Reader XI. It shows the dialog "choose the copy of Adobe Reader to update" under following scenarios:
    1. When it finds more than one copy of Adobe Reader installed on a system. In this case, You need to choose the application that you use, like browse to Applications directory and choose Adobe Reader if that is the location from where you use the application.
    2. When the installer didn't find any copy of Adobe Reader installed on a system which it needs to update. In this case, you may install Adobe Reader XI version 11.0.07 directly from here get.adobe.com/reader/ from the same machine you intend to use it on.
    Please let us know if any of the above suggestion resolved your problem.
    -Shashi

  • The maximum number of PDF documents that can be simultaneous openned in the browser has been exceede

    I'm currently build a WinForms application that uses the built-in webbrowser to view PDF files. However, I just started getting this message. I saw someone's post but in was in the archive section and looks like it was never resolved. So I'm asking for Adobe's help if they're on here to put up a FAQ somewhere describing this error.
    I'm currently on Reader 8.1.2.
    Jeff

    First, no one is addressing Adobe here. This is a User 2 User forum. I'm
    not sure this is really a Reader issue as opposed to a Microsoft issue.
    Microsoft applications have a habbit of holding onto documents until the
    application is closed. Since you are most likely using MSIE, it is
    probably still holding onto the document via the reader plug-in until it
    quits.
    However, if you wish to log it as a Reader bug, here is the appropriate
    link:
    Mike

  • Files sometimes downloading instead of opening within the browser

    I know this has been discussed before but I was unable to find an answer. When I try to open a video file while surfing sometimes it opens and plays in quicktime and at other times it starts to download. How do you set it up to play all of the time instead of downloading? My experience has been with videos and not text files as in previous posts.
    Thanks

    Hi,
    It often depends on the website serving the videos. If they specify the wrong MIME type for the file then Safari will treat it as a regular binary file and download it.
    Can you give examples of sites where you see the differing behaviour?

  • Error opening pdf file, but then it still opens

    I am having trouble when I open a pdf.I am using the code below to open a pdf.
    on mouseUp me
      acro = bafindapp("pdf")
      if acro = empty then
        acrofile = me.pPDF
        alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
        goToNetPage "http://www.adobe.com"
    else
        open the moviePath & "Resource\" & me.pPDF with acro
      end if
    end
    When this is on a button, adobe reader will open, but gives an error saying "There was an error opening this document. This file cannot be found."
    When I hit the ok button on the error notice, the pdf opens.
    Any ideas why I am getting this message even though the pdf opens after dismissing the message would be appreciated.

    The reason I assumed, or asked, whether it was Windows-only is because of your use of the backslash character as the folder delimiter. To make the script cross-platform try the following:
    on mouseUp me
      acro = baFindApp("pdf")
      if ( acro = EMPTY ) then
        alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
        goToNetPage "http://www.adobe.com"
      else
        mPath = _movie.path
        tFile = mPath & "Resource" & mPath.char[length(mPath)] & me.pPDF
        if baFileExists(tFile) then
          OK = baOpenFile(tFile, "normal")
          if ( OK < 32 ) then
            -- see docs for numbers and their meaning
            alert "Error opening file:" && OK
          end if
        else
          alert "File not found:" &RETURN& tFile
        end if
      end if
    end

  • I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    Hi Frank ,
    Please refer to the following link and see if this helps.
    https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
    Regards
    Sukrit Dhingra

  • When openning a PDF file, a new tab will open but it will be blank, it does not download or open any pdf files, this just started the last 3 days....!!!!

    Hi,
    I am on the verge of deleting Firefox from my computer as it has wasted hours of my time, and none of the online trouble-shooting answers are of any help.
    Until recently I could open PDF files in my browser window, and today its impossible to open any pdf file, it will not even download if I choose to download it.
    This issue has been going on and off for nearly a year, and I downloaded Nitro PDF add-on to solve it previously as the Adobe reader add-on didn't do anything. Today In the options menu of applications where I can select the program I want to open the PDF files with I can no longer find the NitroPDF reader as an option, so I choose the Adobe add-on and no matter how many re-starts it refuses to initiate any PDF files, all I get is a open and empty new tab.
    Internet explorer opens PDF files fine, so I know its not computer related.
    I am running Windows Vista Ultimate, Firefox Version 19.0.
    If there is a way of fixing this, please help because currently I am at the end of my patience.
    Regards,
    Emre

    Hey thanx for the help, it worked like a charm.
    I think firefox changed the application lay out, as I used to be able to choose my PDF opener from the list at " Adobe Acrobat Forms Document' where I could choose Nitro-PDF reader, but it has now moved all the way to the bottom like you suggested to the obvious place of "Portable Document Format" section.
    If someone didn't tell me , I wouldn't have scrolled all the way down to be able to find it... it really should be with all its cousins up the top...
    Cheers again..

  • Downloaded certain files from my old computer on a memory stick.Have inputted stick into my new mac and can open PDF files but not xlr,aww or eps files.Is there a solution to this please?

    Transferred certain files to my new Mac from my old computer via memory stick.Can open PDF files but not xlr,aww or wps ones.The important ones are in xlr format.Is there a solution please?

    My guess is they don't care. Most likely they're illiterate and don't know what a colon is for. They probably think it's a little-used character. Remember: these are the people who don't know the difference between "deprecate" and "depreciate".
    I have the same colon problem as you do. But it's not the biggest problem I have encountered in Lion. If it was only that I'd be Mr. Delighted with Lion. There's worse than having a colon - uh -  that won't cooperate. A lot worse, in Lion.

  • Adobe Acrobat 9 - Print certain webpage as PDF file but some of its contents were corrupted

    Print certain webpage as PDF file but some of its contents were corrupted as non-readable alphanumeric.
    Preview of the PDF file shown OK but when printed, its contents were corrupted.
    Adobe Acrobat 9 Professional reinstalled but problem persists.

    It is Acrobat printing to a PDF file using Acrobat 9 Professional because I have no printer attached.
    The preview before printing showed every words OK but when printed to the PDF file, some alphabets and numerics were corrupted and the words were NOT readable.
    See the following:

  • The scroll function on my mousepad is disabled when viewing a pdf file in firefox version 5.0. The scroll works on the pdf, but not on the other tabs. When the pdf is closed, the scroll function returns to normal. Any ideas?!

    The scroll function on my mousepad is disabled when viewing a pdf file in firefox version 5.0. The scroll works on the pdf, but not on the other tabs. When the pdf is closed, the scroll function returns to normal. Any ideas?!

    Hey thanx for the help, it worked like a charm.
    I think firefox changed the application lay out, as I used to be able to choose my PDF opener from the list at " Adobe Acrobat Forms Document' where I could choose Nitro-PDF reader, but it has now moved all the way to the bottom like you suggested to the obvious place of "Portable Document Format" section.
    If someone didn't tell me , I wouldn't have scrolled all the way down to be able to find it... it really should be with all its cousins up the top...
    Cheers again..

  • I have converted a pdf file but it has been saved as a jpg, how do I save it as a word doc?

    I have converted a pdf file but it downloaded as  a jpg not a word doc, how do I save it as a word doc?

    Hi moi person,
    Please provide us more information about the product you are using.
    Also let us know your workflow how did you already tried to convert the PDF document into a word document.

  • In documents I can open pdf files but none of the others

    When I go to documents I can open pdf files but nothing else. Same on downloads. I have lots of info I've downloaded over time and I often use it. Can I just go back and use internet explorer for that and if so how?

    Opening in the side bar is the default for bookmarks that are created via a link or button on a website.<br />
    You can check the Properties of a bookmark via the right-click context menu in the side bar (Ctrl+B; Cmd+B on Mac).<br />
    In the Bookmarks Manager (Bookmarks > Show All Bookmarks) you can click the More button in the Details pane at the bottom right.<br />
    Make sure that "Load this bookmark in the side bar" is not selected.<br />

  • We have a mac laptop and dont have any problems with pdf files but our imac will not open them.  any suggestions

    we have a mac laptop and dont have any problems with pdf files but our imac will not open them.  any suggestions?

    Back up all data.
    In the Finder, select Go ▹ Go to Folder from the menu bar, or press the key combination shift-command-G. Copy the line of text below into the box that opens, and press return:
    /Library/Internet Plug-ins
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

Maybe you are looking for