Accessing PDF files outside the web application

Hi,
I have deployed a web application Tomcat / webapps/ Moto.
The Tomcat / webapps / Moto / resource.jsp file has links
to a pdf file located outside the Moto web app.
The pdf file is in Tomcat / webapps / doc / BAServerConfig.pdf.
Now, I'm unable to access this pdf from the resource.jsp page.
Is there any way i can do this?
I'm not supposed to move this pdf file to any location.
Please suggest.
Thanks in advance,
Phani

I havent tested, but if it doesn't work, it should give you the idea:
<%@ page contentType="application/pdf;charset=TIS-620" %><% response.setHeader("Content-Disposition","attachment; filename="+request.getParameter("id").substring(request.getParameter("id").lastIndexOf("/")+1));
  try{
    FileInputStream fis=new FileInputStream(request.getParameter("id"));
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    byte buffer[]=new byte[1024];
    int length;
    while((length=fis.read(buffer))>=0) baos.write(buffer, 0, length);
    baos.writeTo(response.getOutputStream());
  catch(Exception e){
    throw new ServletException(e);
%>Be aware to not to broke ... %><%..... with spaces or return characters.
And if this work, you can convert it to a servlet and enter corresponding entries in web.xml file.
Hope this help,
OO

Similar Messages

  • Lately pdf files from the Web do not display properly; what is wrong and how can I fix it so I don't have to use IE?

    I am a professor and frequently need to open pdfs of academic journal articles from electronic databases. Within the last two or three weeks, when I try to do this using Firefox, only the first page of the pdf displays and the rest are blank. In addition, a bar appears across the top with the message "This pdf file may not display properly." So I have had to switch to Internet Explorer to open the files and do my research. What is going on and how can I fix it so I can open pdf files from the Web in Firefox and have them display properly?

    My question is simple - why would you put an application in production that has a lot of bugs? To replace a good and steady Adobe product? My customers will believe that I put a pathetic fallible form online. They are not sophisticated on computers so I just tell them to use IE. Ugh
    I must agree with pgwebgirl!

  • Adobe 8 - Unexpected Corrupt or incorrect file type warning when viewing a PDF file from the Web

    Hi,
    On downloading a PDF file from my web site using Adobe 8 on the client machine I expect the file to open automatically however I receive encounter the "File Download" dialog. It has the following warning message: "The file you are downloading cannot be opened by the default program. It is either corrupted or it has an incorrect file type. As a security precaution, it is recommended that you cancel the download."
    This issue did not occur within previously tested versions of Adobe Reader (e.g. Version 5.1).
    On investigating the issue I discovered the factor that results in Adobe 8 failing to open the file automatically is the Content-Type = "application/pdf; Charset=utf-8". However, if I intercept the response and alter the Content-Type to contain only "application/pdf;" the issue on Adobe 8 does not occur.
    I have even tested when the Content-Type contains an empty Charset (i.e. "application/pdf; Charset=") but this issue still occurs. In addition setting the Charset to other encodings (e.g. "ISO-LATIN-7", "iso-8859-1") the issue occurs.
    QUESTION(s):
    1. Why is it necessary for Adobe 8 when opening PDF files from the web to expect no Charset within the Content-Type?
    2. If this was not an issue within previous versions of Adobe surly this is a bug?
    Since I cannot ensure that the Response's Content-Type does not contain a Charset at all please can someone suggest either a work-around or more importantly a solution to the issue?
    Please Note:-
    1. Within Adobe, Edit -> Preferences -> Internet option it's compulsory for our users to have "Display PDF in browser" ticked!
    2. We cannot prevent a Charset from being present within the Content-Type of the response sent to the client, hence this issue.
    Many Thanks in advance,
    Martin.

    Bill,
    This is exactly the same behavior I observed when I rendered a PDF stored in a database through a .NET page. If I chose to save it, it would open fine after the save, but if I chose to open it in the browser without saving it, I would get the error.
    The problem was not with the PDF or Acrobat. It was with the way I was delivering the PDF. Putting the following code before my binarywrite fixed the issue completely:
    Response.ClearHeaders()
    Response.ClearContent()
    Response.ContentType = "application/octet-stream"
    Response.AddHeader("content-disposition", "attachment; filename=" + saveFilename)
    where saveFileName is the name you want to give the PDF.
    You can use 'inline' instead of 'attachment' above if you just want the PDF to open (no option to save first). You can also use 'pdf' instead of 'octet-stream' (not sure the difference).
    The trouble seems to be that .NET puts some info in the header and/or content by default prior to anything your code says to write. If you don't clear this, IE has an issue with it. Other browsers seem to ignore it.
    Bottomline is that this is an issue the website programmer needs to fix and is not something the user can fix by changing some setting(s).
    I hope this helps.

  • Visual Studio 2013. Viewing a PDF file via the Web Browser control in Windows 8.1

    I am writing a Windows Forms application in which I need to view PDF files via the Web Browser control. When the control is given the Navigate() command, Windows takes over and asks which program I want to open the file with. All was fine with VS 2010 and
    XP. I have un-installed "PDF Complete", which was the default PDF viewer, but I now get asked for an alternative.
    Thanks in advance.
    Mike Saunders

    Hi Mike,
    It seems that we could use Internet Explorer to open a local .PDF file if it has the Adobe Reader. I doubt that the web control would be related to it. Like the MVP's suggset in the following thread, maybe it would be related
    to certain plug-in tools in your side like the adober reader.
    Reference:
    https://social.msdn.microsoft.com/Forums/en-US/a717117e-41ae-4775-9c28-d5a1042b396e/pdf-is-not-opening-in-web-browser-control-in-vbnet?forum=vbgeneral
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • When attempting to open a hyperlink to a PDF file on the web from a Microsoft WORD for Mac 2011 (14.3.9) document, Safari 7.0 instead displays the file as text?

    When attempting to open a hyperlink to a PDF file on the web from a Microsoft WORD for Mac 2011 (14.3.9) document, Safari 7.0 instead displays the file as text?

    As seen in http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/has-the-word- 2011-for-mac-invisible-toolbars/018a3ab6-0570-4ad5-abf8-5b6427fdde3e?msgId=e111b f0a-0e32-4fa3-9536-f349dad8439d
    and it worked for me:
    1. Quit Word
    2. In the Finder's menu bar, select Go > Go to folder and type or paste: ~/Library/Preferences/
    3. Click on Go
    4. Locate the preference file com.microsoft.Word.plist, then Option-drag it to the desktop to create a backup copy
    5. Go to Applications/Utilities and open Terminal
    6. Paste the following bold command at the $ prompt (it's a single line):
         defaults write com.microsoft.Word 14\\Toolbars\\Show_HIToolbar -boolean TRUE
    7. Press Return and then quit with Command Q
    8. Start Word and test. If the fix works, trash the backup file in the Desktop file. Otherwise, restore it.
    In the original source the author also mentions the change in Word 2008

  • Help - "Acrobat is being used by another application and cannot open PDF files until the other application is closed."

    Hello,
    I searched this site and google for this error terminology and come up dry.  I support a user who has been for years using Acrobat 5 (yes, I know...) to read files in a client DB program, as well as other PDF files on their PC.  In the last week or so, they have started gatting this error "Acrobat is being used by another application and cannot open PDF files until the other application is closed." any time they attempt to open a PDF file attached to an email (via Outlook).
    It is my understanding that they cannot upgrade to a newer version of Acrobat because of limitations of their client software, but had not previously had any issues viewing PDF notes from the DB, and PDF attachments in their email.
    I have tried uninstalling and re-installing, as well as tried using Adobe Reader 7 & 9 in conjunction with Acrobat to try to get around this issue, but have not been successful.
    Any ideas?
    Thanks,
    Jesse

    I don't have an answer to your technical problem. The product I assume is Acrobat that you are talking about (based on the post title), Adobe is the company name. This is a good place to ask questions on Acrobat if folks can figure out what you are talking about. They will ask for the product version number (like AA9.3.3), operating system, and other applications if appropriate. Also, just what you are doing that generates the message.
    As for Adobe, you are not likely to get an answer from them here in the user forum. You will be lucky if you can get an answer if you can contact them and not be on hold for more than an hour (sorry, this is why a lot of folks end up in the forum).
    So, to help others try to answer your question, what are the products and versions involved? What OS? What are you doing when the message comes up.

  • Bug:Downloading pdf file from the web,file name in dialog box populates with incorrect file name

    Hi Gurus
    When downloading any pdf file from the web using adobe Reader X the file name dialog box populates with incorrect file name
    compared to the saved file name of the document downloaded.
    Clarity
    1. Download any pdf file from the web
    2. Click File, Save as note the populated File Name
    3. Compare the populated file name with the saved file name of the documant yuo are downloading.
    4. The file Name is incorrect...
    Is there any work around on this issue?Can someone please help?..
    OS:Windows7
    Reader: Adobe Reader X
    I've tried a couple of other versions and still get the same results...

    Are you downloading the file (right-click, save link as), or just opening it by clicking it?
    If the latter, then what happens is the file is loaded to the temporary internet files folder by IE and assigned a temporary name, which is then used when you're trying to save it.
    You can test this out by going to File - Document Properties before trying to save and looking at the file's location.

  • I am having a problem where pdf files on the web (i.e., links in a Word doc) open after an extended time and only as gobbldygook ( a file containing a series of characters and letters that make no sense).  This also happens for another Mac user coworker

    Hi There:  I am having a problem where pdf files on the web (i.e., links in a Word doc) open after an extended time and only as gobbldygook ( a file containing a series of characters and letters that make no sense).  This also happens for another Mac user coworker in my office, while the PCs don't have this problem...  Any help/suggestions for a fix would be most appreciated! 

    Just adding more info - MacBookPro running 10.5.8 and using Safari as the browser.  The problem comes and goes - sometimes the linked Word files will open OK, n others its just a strring of crazy characters... 

  • HT5678 I have problems saving pdf files in the web when I use Safari. I don't have this problem with firefox

    I have problems saving pdf files in the web when I use Safari.  I don't have this problem with firefox.

    do they save ok if Safari - Preferences - Security - Allow all other plug-ins is unchecked ?
    If so, likely an adobe or other pdf plugin
    Re-check the setting above & quit any browsers,
    Look in this folder by triple-clicking the line below, then ctrl-clicking it & choosing Services - Open
    /Library/Internet Plug-Ins/
    remove anything with pdf in the filename & test again
    Sometimes, plug-ins can be in the User Library folder :
    ~/Library/Internet Plug-Ins/

  • Opening PDF files on the web with IPad

    Hi everyone
    I am having difficulty opening some (but not all) pdf files on the web with my IPad. When I click on the icon it comes up with approx half of the first page of the document, but nothing else. It also does not provide an "open in" bar. Any thoughts on what is going on here?
    With thanks, Mike.

    Thank you for following up. We often have people reporting similar problems and I suggest they follow up with the website owner but I rarely hear back from the original poster so I'm never sure that this is indeed the problem. Ironically, serving a document for mobile is almost easier than serving it to a desktop browser because there are no plugins to get in the way. That said, a lot of website owners have gone through pains to do plugin detection and user authentication and authorization and mobile represents another case that they would need to handle on top of what they already do.

  • "Adobe Acrobat is blocked" - Where to I accept the end user agreement which will enable me to access Pdf documents on the web?

    I keep getting this message when trying to open documents from the web:
    "Adobe Acrobat is blocked" - 
    Where to I accept the end user agreement which will enable me to access Pdf documents on the web?
    The Adobe website recommends this: (did not solve the problem)
    Safari 7 and 6.1 block PDFs | Acrobat, Reader
    Thanks for any help solving this annoying problem!
    OSX 10.9.3
    Safari 7.0.4
    Acrobat Pro 11.0.0

    Hello Isakten:
    Thanks so much for your reply!
    I already have Adobe Reader 11.0.7 and Adobe Acrobat Pro 9 installed.
    Following your instructions, I then selected Reader as the desired Adobe product to open all PDFs. and save that choice. Still no difference, the same black screen and statement about the EULA shows up…
    http://www.nhgastro.net/patients.html
    BTW, this is the website that I was accessing……note the link to download and print the pdf which triggers the EULA page.
    and also downloaded the latest version of Reader via their link….but to no success…..
    This all started by itself months ago, I did no newer installs or settings changes, none……
    Any other thoughts?
    Thanks so much,
    Steve

  • Problem of opening PDF files on the web

    I have installed the latest version of Acrobat Reader, but I still couldn't read some PDF files on the web, what should i do?

    Hi wings57638543,
    1. Which browser are you using?
    2. Are there some specific files that you are unable to load in the browser? Can you share the link?
    3. In Reader DC, go to Edit->Preferences->General and click on "Select As Default PDF Handler" button. Then try loading those PDFs.
    Thanks.

  • ? Some pdf files from the web will not open, some will.

    Some pdf files from the web will not open, some will. I am using Adobe Reader 10.0.1 on an 8-year old puter I have just upgraded to 2G of RAM. It worked fine before with 256K. When a file won't open I get error message "There is a problem with Adobe Acrobat/Reader. If it is running, please exit and try again (103:103). Have uninstalled and reinstalled all Adobe products several times. Ideas?

    Good luck with that. Adobe10.0.1 is a bug infested BAD program. Look at the posts relating to this issue for the last 3 days. Many, many problems. Support is no help.

  • Can't read pdf-files from the web

    Some pdf-files from the web (using Safari 6) is not readable on my iMac, OSX 10.7.4.
    I get a lot of
    instaed of text.
    Why?
    /Karin

    It happens even to me (iMac late 2006, OS X 10.6.8, Safari 5.1.7(6534.57.2)), but instead of ??? I get black screens. Here some links to several PDF files:
    http://www.heathrowairport.com/static/Heathrow/Languages/Downloads/italian-secur ity-guide.pdf
    http://www.crs.lombardia.it/ds/ccurl/487/15/2008_10_15_Manuale_di_installazione_ e_configurazione_del_CRS_Kit_per_Mac_V1.0.pdf
    http://tda.panasonic-europe-service.com/docs/2z508fef28z3z36c0fz6974z706466z23zc 6217222fafecd42377558ba5cd29331bfd3c26a/tsn2/data/EU/TXP42ST50E/OI/890961/TQB0E2 271C.pdf
    http://www.trenitalia.com/cms-file/allegati/trenitalia/treni/Frecciargento_sched atecnica.pdf
    Luciano

  • I converted a pdf file to the web but it moved me the picture to the left of the screen

    Hello Friends
    I converted a pdf file to the web but it moved me the picture to the left of the screen
    Why does this happen?
    have a nice day!

    thanksssssssssssssssssssssssssssssssss@@!!!!
    You were helpful to me
    And another small question
    In my web(http://josephones.com/)
    At bottom left corner
    You can see four text fields
    How can I make this contact form?

Maybe you are looking for

  • What happens to my pictures on my iPad 2 once I download iPhoto

    What will happen to my photos on my I pad2 once I download the new iPhoto that have just introduced for  Ipad3 will they be duplicated or can I get rid of the photo App that's on my I pad than.? I don't want double of everything

  • Can't open Adobe Muse

    Hi! I installed Adobe Muse CC a couple of days ago. When I tried to open it today, a dialog box appeared with the following: it is necessary to have more account information to use adobe muse. If you wan't to continue, you have to log on" I pushed th

  • Runtime.exec() with .bat-files in a jar

    Hi All, I've written a java-Program, which calls .bat-files per Runtime.exec() for some OS-specific tasks. Everything works fine, but if I want to pack the whole code and the .bat-files into several jars, I can't get the bat-files to run. I have trie

  • JNDI connection creation timeouts

    Hi, I've a question concerning connection creation timeouts. The Tutorial (http://java.sun.com/products/jndi/tutorial/ldap/connect/create.html) says "By default, this timeout period is the network (TCP) timeout value, which is in the order of a few m

  • 10.1 Grid View Album Song "Name" Column Gone?

    In 10.1, Grid View, when an Album is selected and its individual tracks are shown, the "Name" column is no longer visible and there is no way to turn it back on, either in the contextual menu accessed by right-clicking in the column header or in View