Need HELP! Opening a PDF file from different URL

I have a application that links to viewpdf.class. This class file will go to the FTP where the pdf file is located and open it. How do i do this using java? Here is what I have.. .i'm stuck
URL url = new URL("ftp://user01:[email protected]/"+ folder_name +"README.pdf;type=i");
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream();thanks Tony
here is how it looks like if it is on the local host.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class viewpdf extends HttpServlet
    private ResourceBundle rb;
    public viewpdf()
        rb = ResourceBundle.getBundle("LocalStrings");
    public static void streamCopy(FileInputStream fileInputStream, ServletOutputStream servletOutputStream)
        throws IOException
        if(fileInputStream == null || servletOutputStream == null)
            return;
        byte abyte0[] = new byte[8192];
        int i;
        synchronized(fileInputStream)
            synchronized(servletOutputStream)
                while((i = fileInputStream.read(abyte0)) != -1)
                    servletOutputStream.write(abyte0, 0, i);
    public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
        ServletOutputStream servletOutputStream;
        String filename;
        String output;
        FileInputStream fileInputStream;
        servletOutputStream = res.getOutputStream();
        res.setContentType("application/pdf");
        ServletContext servletcontext = getServletContext();
        filename = req.getParameter("file");
        String folder_code = req.getParameter("fold");
        try{
            filename = servletcontext.getRealPath(rb.getString("file_location")) + "/" + fold + "/" + file;
        fileInputStream = null;
        fileInputStream = new FileInputStream(file);
        streamCopy(fileInputStream, servletOutputStream);
        catch(FileNotFoundException e)
        filename = servletcontext.getRealPath(rb.getString("file_location")) + "/filenotfound.pdf";
        fileInputStream = null;
        fileInputStream = new FileInputStream(file);
        streamCopy(fileInputStream, servletOutputStream);
}

That servlet already is Java. And the servlet code isn't what "opens" the PDF, it's the browser that sends the request that does that. I'm assuming that when you say "open it" you mean to start up an instance of Adobe Acrobat and ask it to display the document.

Similar Messages

  • Need help opening a pdf file

    How can I get help opening a pdf file?  I have been asking for help for over an hour now, I need this file, it is password protected,
    and I have set a new password, with still no help, still can't get the file to open, just what do I need to do, it is my 2011 tax return,and
    I need to have it. I hope someone cares enough to help me with this. I am so frustrated at this point, I just don't know where to turn now.
    Janet Lechner
    [email address removed]

    What is your operating system?
    What is your Adobe Reader version?
    What is the problem when trying to open that PDF document?
    Who password-protected that file?

  • Problems opening a pdf file from a URL protected by OAM with M.Explorer

    Hello,
    we have protected a web portal with OAM. When we access a URL which is a pdf file with Mozilla Firefox, the file is retrieved and opened correctly, but when we try to open it using Microsoft Explorer it won't open. If we disable OAM the pdf is opened without problems. We set Microsoft Explorer security level to the lowest possible value but the problem persists.
    Can anyone give us a hand to solve this issue?
    Thank you

    Hi Francisco,
    In the AccessGate screen for the WebGate, if you have the CachePragmaHeader and CacheControlHeader set to "no-cache", try setting them to "public" (or blank), restart the web server, and see if that resolves the issue.
    Regards,
    Colin

  • I cannot view PDF in Firefox at the first time but once I manually open the PDF file from my local computer, I can view other PDF files via Firefox webbrowser

    I install Adobe Acrobat 9 in my laptop which runs on windows 7. I use Firefox 3.6.8 and have the problem with the PDF file. The problem is I cannot open the PDF file in Firefox web browser at the first time I launch firefox. It shows a warning box without any message. Only OK button is shown so I can close it. However, if I manage to open the PDF file from my local computer by just using adobe acrobat itself then the PDF can be opened in the Firefox web browser. I followed the instruction on the mozilla help but nothing works for me. The problem still exists. I wonder if anyone have the same problem like me and know how to solve this. Thank you so much

    Hi there!
    I cannot help you, but I think we have a common problem: We got a system here running Vista SP1 with Acrobat 9 standard on it. When we open a pdf file it works normally, but when we open another pdf file, we see the first one in that second window.
    Think that missing option to watch several files within a single window-thing messed up more than meets the eye ... but as we just purchased the 15 licenses, we have to use version 9.
    I didn't find any clues on this problem, but I will post any new hints I get.

  • Can't open web pdf files from my Reader DC because my IMac wants a completed license agreement to use Reader and I never saw that page during installation.

    Can't open web pdf files from my newly installed Reader DC because my IMac wants a completed license to use agreement to Reader, and I never saw that page during installation.  How do I get past this?

    You need to accept the EULA on first launch of the Reader DC application.
    Go to the Applications folder and launch Adobe Acrobat Reader DC. 
    This will bring up the EULA.
    Select the "Agree" button if you agree with the terms
    Assuming you selected the "Agree" button, Reader DC should open.
    You should now be able to open PDF files in your web browser.

  • Open the pdf file from forms6i

    Hi,
    how to open the pdf file from forms6i.
    can anyone help me regarding this.
    Thanks,
    Ansaf.

    Hi,
    The HOST built-in does not return any error or message back to the Form.
    You will have to use some other means to first find out whether the file exists or not. E.g. you could use TEXT_IO.FOPEN to open the file in Read mode. If the files is not found the handle returned will be null, and that will be condition you have to process to show a message or pop an alert.
    Make sure you close the file with FCLOSE, irrespective of whether the file is found or not, before you open the File for viewing.
    Regards,

  • Unable to open large PDF file from the Attachment list.

    Hi Gurus,
    Users had attached 10 PDF file in the work order attachment list and his supervisor is trying to open the PDF file from the work order attachment list and he is able to open 9 PDF files without any issue, but 1 PDF file is giving the error message as "Database error for <GET DATA FROM KPRO>" and then select ok, we are getting the below message.
    Window cannot find u201CC/Documents and Settings/b2m/SaoworkDir/5015851 Vendor data sheets B&P 2010 SDown XXX .PDFu2019. Make sure you typed the name correctly, and then try again. To search for a file, click the start button, and then click serch.
    Looks like this particular file is not transferring to the SAP work directory.
    Could you please check and suggest us as to how to fix it.
    Thanks & Regards,
    Srivas

    Hi,
    Thanks for your reply.
    We verified  your OSS notes it's not relevant to us Because our issue is while opening the PDF aatchement it is not transferring to my SAP Work Directory because of that reason we are getting the KPRO error. When I'm opening the other PDF files it's transferring to my SAP Work Directory and it's automatically open without any issue.
    Please check and suggest.
    Thanks,
    Srivas

  • How do I get Adobe Acorbat to open a .pdf file from a sharepoint library without having to checkout the file

    I have a customer that is using Adobe Acrobat pro version 10.1. When they try and open a .pdf file from a SharePoint site, the user is prompted to check out and open the file or open the file. Is there a way to get Adobe Acrobat to open the .pdf file without prompting to check out or open?
    Thanks
    Jim

    This is mostly a lion thing, rather than a PSE thing. To disable applications opening where they left off last time for all the programs on your computer, go to system preferences>general and untick this box:
    You can also do on a per-program basis, but it's more complicated and the best thing to do is to search around for directions on the web and see which way is least uncomfortable for you.
    There's an odd little glitch in PSE that it opens the last image you had open, even if you closed it before quitting last time. Adobe says this is correct behavior, but of course it isn't.

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • Opening a pdf file from the internet.

    Everytime I try to open a pdf file from the internet a window pops up and tells me that my adobe reader has a problem or gives me a blank page.  I have ie 10, adobe reader XI and adobe acrobat 8 pro.  All this is on win 7.  When I installed the acrobat 8 pro it could not find the adobepdf.dll.  I searched the disc, and tried to direct the installation to it but it would not accept it.  What can I do to correct this issue?

    Yes, unlike earlier IE versions, IE10 has only one executable, but it can run in 32-bit or 64-bit mode.
    Some details: http://www.sevenforums.com/tutorials/280434-internet-explorer-10-enable-32-bit-64-bit-ie10 -windows-7-a.html

  • Why cant I open a PDF file from a cd-r that I burned into this cd myself at work on my personal laptop? I have the same version of Adobe.

    Why cant I open a PDF file from a cd-r that I burned into this cd myself at work on my personal laptop? I have the same version of Adobe.

    What happens when you try? Have you saved to your computer and then tried to open it?

  • Open an xml file from a URL

    i am trying to open an xml file from a URL.
    i have been using the standard (i think!) xml suite, part of the System Events. is this possible? is this the best way? are there alternatives? any good tutorials of how to use it too?
    the file i am trying to open is: http://www.tvrage.com/feeds/episode_list.php?sid=xxxx
    where "xxxx" is a number of a show, e.g. 2930 is buffy
    regards
    jingo_man

    It works!!
    I used the URL and BufferedReader classes to fill the parser. Here's how:
    // create a new object of type URL
    URL xmlURL = new URL( "http://ServerName/DbName/PageName?OpenPage&username=myname&password=mypassword");
    // Create the SAX2 parser
    SAXParser saxParser = spf.newSAXParser();
    xr = saxParser.getXMLReader();
    // Set the ContentHandler
    DefHandlerClass myHandler = new DefHandlerClass();
    xr.setContentHandler( myHandler );
    // read the URL stream into the BufferedReader
    BufferedReader in = new BufferedReader( new InputStreamReader(xmlURL.openStream()));
    // parse the document
    xr.parse( new InputSource( in ) );
    // close the input stream
    in.close();
    PjR

  • RoboHelp for Word 8.0 - can't open a pdf file from help topic

    running RoboHelp for Word 8.0 on a Windows 7 machine. I produce WinHelp for one of our clients.
    I just converted an old online help system from RoboHelp 7 to RoboHelp 8.
    one of my topics has a button to launch a pdf file
    {button Transport Feature Chart, EF(`GFC.pdf', `', 1, `')}
    I can generate the hlp file, launch the help and open the topic but cannot open the pdf file when I click on the button.
    any ideas?

    I've just tried this in RH8 and have discovered that the EF macro only seems to work with certain file types. For example, .TXT and .LOG files do work whilst .PDF and .DOC don't. I'm beginning to wonder if there has been something that has changed between RH7 and RH8 along security lines? Just added my 2p as I haven't used WinHelp for over 10 years!
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Open Multiple PDF files from Production order/Routing

    Hi Everyone
    We are in ECC 6.0 environment. We have a scenario where multiple documents were attached to single operation and also at multiple operations. But when I was trying to open these PDF documents, only the last file was getting opened and closing the previous file. How can I open multiple PDF files at one time from Production order or Routing?
    Any help is appreciated.
    Regards
    Prasad

    Hi Prasad,
    from DMS standard I regret but such a functionality is not available. In the standard originals can be opened only one after another.
    I think for realising this functionality an individual modificatoin is necessary.
    Best regards,
    Christoph

  • Open a pdf file from a path with GetFileFromPathAsync

    Hi, I'm trying open docxs and pdfs files from her path on Windows Phone 8.1. I could achieve this with images with the next line:
    await StorageFile.GetFileFromPathAsync(path);
    The problem is that when I try bring other type of files as the docxs or pdfs I have a exception E_ACCESSDENIED. The capabilities of de app are well configured to acces a the files of phone but I don't know because
    El problema es que cuando intento traer otro tipo de archivos como los docx o pdf tengo un problema de E_ACCESSDENIED . Las capacidades de la aplicacion estan bien configuradas para acceder a los archivos pero no entiendo porque no puedo get this others
    files.

    I have addressed a similar issue in this
    forum post. You need to add the File Type Associations for the file types your app needs to access. This is required when accessing files from DocumentsLibrary and RemovableDevices.
    Abdulwahab Suleiman

Maybe you are looking for

  • How can I get my network printer to print in color?

    I have a Dell 3110cn color printer on my network. Since I did the Maverick update the printer will no longer print in color only b&w. It's using a generic printer driver. I had no problems before the update. It's a great workhorse printer. How can I

  • Affinity queries ("customers who bought this item also bought...")

    Hi, Do you know the feature of many web shops, where you can see similar items (i.e. "customers who bought this item also bought...")? A simple approach would be to return similar items from the latest orders. What I would like to list are products,

  • MSI Gaming 9 AC Faulty Wi-Fi Card

    I installed an MSI Gaming 9 AC into my build not long ago, and the wifi adapter stopped all pci devices working. I just took it out and left it out as I used ethernet anyway. I (stupidly) decided to take apart the wifi module to see what was going on

  • Laptop Replacemen​t Battery

    Hello, I have an HP Pavilion g6-2111us Notebook. My battery is dying quite fast so I am looking for another one. My question is this: Do I have to have a battery that says it is for my exact model of laptop? Or is it ok for me to get just another 6 c

  • Table column header text orientation

    Hi , Is it possible using UI element TABLE or ALV component SALV_WD_TABLE to set the column header text orientation to 90 Degrees?  Like in Excel if you right click on cell then go to format cells then go to alignment tab where you can set text orien