How can i show pdf in my web application?

if the pdf (or else) file is under web content folder is simple, i can make a link to the resource, but if is it out of the .war file i deployed??
I know I set a outside folder in web server classpath, so i can get URL and then the InputStream from the pdf file, like this:
URL url = null;
    url =request.getClass().getClassLoader().getResource("file.pdf");
    InputStream is = url.openStream();
    response.setContentType(".......");  // how i must set???
    OutputStream os = response.getOutputStream();
    byte[] bytearray = new byte[1024];
    int bytesread = 0;
    while( (bytesread = is.read(bytearray) ) != -1 )
    os.write(bytearray, 0, bytesread);
    os.flush();
    is.close();The question now is: how can my browser understand opening the response by the pdf reader?

Set the response headers. Especially the content type, content disposition and content length. You may find this example useful: [http://balusc.blogspot.com/2007/07/fileservlet.html]. All content types (mime types) can be found here: [http://www.w3schools.com/media/media_mimeref.asp].

Similar Messages

  • How can I rename the "name" on "Web Application List " page

     I have a quesiton need your kindly help . I'm novice in this field
    on "Central Administration" website
    "Administration management"--->"Sharepoint Web Application Management"--->"Web application list"
    here will show all of web application mapping information
    Name                                             URL
    SharePoint - 24824                          http://home:8081/
    SharePoint - 80                               http://home/
    SharePoint Central Administration v3   http://home:8080/
    I want to change "SharePoint - 24824" as "SharedServicePortal", how can do it

    Unfortunately by central admin UI you cannot change a web application name.
    So there are two ways to do this
    First as suggested above you have to delete web app and recreate again.
    2nd one you can use powershell script to modify webapp name as below
    $a=Get-SPWebApplication | where {$_.Name -match "Old web app name"}
    $a.Name
    $a.Name="New web app name"
    $a.Update()
    Get-SPWebApplication | where {$_.Name -match "New web app name"}
    Hope that's helps you.
    Regards
    Soni K

  • How can I show the progress of web page loading only in the right bottom of screen?

    When I downloaded the first Firefox upgrade that had no progress bar, I somehow found out how to stop the new progress bar (that shows all the progress in web addresses rather than a progressive bar) from jumping around in the bottom left or right of the screen. I had it only appearing in the bottom right of screen. Now a new version of Firefox has been downloaded and is once again jumping around from left to right depending what else is showing on the screen. Most annoying, how do I get it to always appear & remain in only the bottom right again.
    Thanks in anticipation, Katnko.

    Hi Cor-el, thanks for your help. Is there a help file anywhere for Status-r-Evar? I don't understand which way to set all the Options, as it is great having the green status bar showin once again, but I wouldn't mind keeping the name of the file that is progressing as well. Do you understand what I mean? Thanks, Katnko

  • How can I Show PDF in C# and disable user interaction

    I am testing the C# example project BasicIacOCX. I can run the project and there I can hide the toolbar of the Acrobat-control (pdfWindowLeft.setShowToolbar(false);). But if I press F8 the toolbar is visible again. Now I found out nothing how I can disable that the user can press F8.
    Any ideas?

    Correct, there is no support for permanent hiding of the toolbar.  Also, with Acrobat X, the whole idea of a "toolbar" has changed.

  • How can I read pdf files from LabVIEW with different versions of Acrobat reader?

    How can I read pdf files from LabVIEW with different versions of Acrobat reader?
    I have made a LabVIEW program where I have possibility to read a PDF document.  When I made this LabVIEW program it was Acrobat Reader 5.0.5 that was installed on the PC. Lather when the Acrobat Reader was upgraded to version 6.0, there was an error when VI tries to launch the LabVIEW program. And Later again when we upgraded to Acrobat Reader 7.0.5 I must again do some changes and rebuild the EXE files again
    It isn't so very big job to do the changes in one single LabVIEW program, but we have built a lot of LabVIEW programs so this take time to due changes every time vi update Acrobat Reader. (We have build EXE files.)
    The job is to right click the ActiveX container and Click "Insert ActiveX Object", then I can brows the computer for the new version of acrobat Reader. After this I must rebuild all the "methods" in the Activex call to make the VI executable again.
    Is there a way to build LabVIEW program so I don't have to do this job every time we update Acrobat Reader?
    This LabVIEW program is written in LabVIEW 6.1, but I se the problem is the same in LabVIEW 8.2.
    Jan Inge Gustavsen
    Attachments:
    Show PDF-file - Adobe Reader 7-0-5 - LV61.vi ‏43 KB
    Read PDF file.jpg ‏201 KB
    Show PDF-file - Adobe Reader 5-0-5 - LV61.vi ‏42 KB

    hi there
    try the vi
    ..vi.lib\platform\browser.llb\Open Acrobat Document.vi
    it uses DDE or the command line to run an external application (e.g. Adobe Acrobat)
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • Using the value "Image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of preconfigured file types (.jpe, .jpg, .jpeg, .?

    On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
    Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
    <input type="file" name="file" accept="image/*" id="file" />
    mimeTypes.rdf does not seem to allow this.

    ''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
    You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
    <pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
    For details, see
    * [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input]

  • How can i export PDF as a Booklet formate in InDesign?

    Hi,
    I am currently working on 48 pages book. Book design is complete and i want to send it to printer as a spread in Booklet formate. how can i export pdf as booklet format?

    In this situation we strongly needed PDF in booklet layout. so is there any suggestion for saving that instead of printing?
    You have to save a postscript file using the Adobe PDF 9.0 PPD, as Eugene is showing in #6, and distill the .ps file to PDF using Distiller.

  • How can we show data in rows when it is in Columns........

    I have strucked with a simple but a complex problem.
    I have a Report with data in vertical rows..need of the hour is how can we show that data into column structure.
    here is the table sample which i have in Database..
    Location      chrg_type    Effective_date
    xxxxxxx        xxxx          xx-xx
    thhis is the structure in effective date we have several months in it in a single column i want show the effective date or effective month in various columns instead of a single column.
    my required table is....
                                Effective_date     Effective_date
    Location      chrg_type     xx-xx              xx-xx
    xxxxxxx        xxxx          xx-xx
    any tough heads?????

    Hi Sunil,
    Your 1st problem is that you are going to need one more field to accomplish you goal. What type of data do want under your new date columns?
    Anyway, once you have that you need to move on to how to move the data out into columns based on date.
    Try something like this.
    0_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',CurrentDate) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',CurrentDate)
    THEN {tbl.DataField}
    1_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',DATEADD('m', -1, CurrentDate)) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',DATEADD('m', -1, CurrentDate))
    THEN {tbl.DataField}
    2_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',DATEADD('m', -2, CurrentDate)) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',DATEADD('m', -2, CurrentDate))
    THEN {tbl.DataField}
    ... Repeat this process until you have all of the columns you need, following this format.
    Hope this works for you,
    Jason

  • Forms 6.0-- How can I show records in a block in different colours.

    In a multi record block, how can I show few records in one colour and few more in a different colour depending on a condition.

    Use DISPLAY_ITEM.
    This will change the visual attribute of the item in the current(!) record,
    set_item_property changes the attributes of the item in all(!) records.

  • How can I delete PDF files from my iMac desktop?

    How can I delete PDF files from my iMac desktop?

    Not on my system,When I try to dump if off in the trash it will not go. I get a message that says this file cannot be removed. I also tried going to File and clicking on Move to Trash. No dice.

  • How can I transmit PDF files from my Mac to my iPad, How can I transmit PDF files from my Mac to my iPad

    How can I transmit PDF files from my Mac to my iPad, How can I transmit PDF files from my Mac to my iPad

    Yes you can definitely do this. You'll need an app on the iPad that handles PDF viewing and editing. There are many around - two of the best I've seen are GoodReader and PDF Expert.
    In iTunes when you iPad is connected to your PC, go to the Apps tab and scroll down and you'll see the File Sharing section. You can drag files to there to share them to your iPad.
    You could also look at online file sync services like PDF to ePub Maker if you prefer not to have to connect your iPad to a PC

  • How can I share PDF documents in Ibooks

    How can I share PDF between my Apple devices with Ibooks? I have on my Ipad a lot of PDF manuals that I want to see on my other devices so I don´t need to download them to Ibooks on every device. Sync is on in the setup but it seems only to work with books and not PDF.

    No - it will not work with PDFs. You might consider another cloud service such as Box, DropBox, or Google Docs.

  • HOw can i show a table(name given in parameters) in a report program

    I made a report in which there is a paremeter asking for a table name ....
    PARAMETERS TBLLE_NAME(10) OBLIGATORY.
    Now when I enter the table namke then how can i show its values....
    HINT:- We have to use fiels symbols....AND THE USER CAN ENTER ANY DDIC TABLE NAME having some records ...........

    You can display the contents of the DB table inputted using ALV.
    Pass the Structure name as the DB table name inputted.
    Use CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic table of the same structure as the DB table passed.
    Once the above steps are done, the internal table with data can be displayed using ALV.
    Reward points for all helpful answers.
    Thanks,
    Balaji

  • How can I show album art in the mini player when playing songs from a plugged in iPhone?

    How can I show album art in the mini player when playing songs from a plugged in iPhone?
    When I play from my phone and switch to the mini player it's always showing the music notes in the thumbnaill. It'd be nice if it could get album art off of the phone.
    I'm on iTunes version 11.0.4.4

    He @mracole,
    it is very nice that you post a solution to complete the library with artwork for album's that do not have an artwork. Your solution perfectly addresses the problem for assigning artwork, BUT this thread is about CHANGING artwork for albums already uploaded into iTunes Match. Just try to replace for example a blue artwork cover for an album with a red one. If you made it in a simple way (without deleting the album from iTunes Match and local changes on the files with an external ID3-Application or 2 or more iTunes libraries on different Mac's) this is the right place to give a solution. I really tried for hours to change the artwork to make them visible in landscape cover flow mode on my iPhone5. In rare cases I made it, but then the covers sometimes where restored to the old onces - exacly how it is mentioned by Starhawk
    As long as there is no simple way to change the cover of an iTunes Match stored album (you can change title, artist and so on without hitting "update iTunes Match" over all distributed Library on different devices - this date will be synchronized almost instantly) I considered the behaviour from iTunes as BUGGY! For me the local artwork cache (and if there is any iCloud artwork cache - I don't know) do not interfere with iCloud. Even when I delete the whole local cache (album artwork music - everything) I do not manage to change the artwork.
    Regards from Munich, Germany

  • How can i show Bcc in my outgoing emails for Mac Lion 10.7.2

    How can i show Bcc in my outgoing email for Mac Lion 10.7.2  Bcc does not highlite in View.
    Noomee

    Reset the SMC: http://support.apple.com/kb/ht3964
    Should fix just this sort of thing.

Maybe you are looking for

  • SharePoint 2010 Search "Did You Mean" | How does it work?

    My customer has raised a concern that "Did you mean" functionality works inconsistently and issue is explained as below: 1. When I search for misspelled word such as "Maketting" , search page displays the option "Did you mean ""Marketting"? 2. When I

  • HTTP call in a workflow using GetFolderByServerRelativeUrl returns Forbidden

    This is using Office365 SPO with a 2013 workflow being created in the 2013 Designer. We are trying to make a workflow (whose steps will later on be part of a larger) that simply does an HTTP GET call. We have a url variable set to https://xxxxx.share

  • My mac wont power up

    My emac has suddenly stopped working. It worked fine one day and then nada. I have tried different power cables from other emacs with different sockets and still no joy. It is a 1.25ghz emac and I am puzzled as to why it has just stopped. Does anyone

  • Remote Domino LDAP Address Book

    hi people.. we have sun java communication suite up and running. recently my boss has asked to incooperate domino address book in the sun java messaging server. i have followed the steps in the Communication Suite Admin guide, adding an additional re

  • Where the **** are all my export options now in Quicktime X

    Don't tell me you actually removed all the pro options I had from WMV to FLASH to on2 to H264 and only gave us like 2 options to export? Where are the custom settings, the screen sizes, frame rates etc. Is this a joke or am I missing something? I am