Sending a PDF file from applet to screen?

Discussion in 'Java' started by Ramon F Herrera, Jul 7, 2003.

  1. My Java applet collects some parameters from the user,
    which are sent as arguments to the web server via GCI.
    The server in turn receives the request, execs the
    *.gci app which prepares a PDF report to the user's
    specifications, end e-mails the report to a given e-mail
    address.

    All the above is working well, and my question is about
    a very common feature which I don't know how to implement
    in Java: if the user clicks on a button, the PDF file should
    be send to (stdout?) the screen for immediate viewing as
    opposed to e-mailing.

    This feature is very easy to implement in HTML, even for
    a complete HTML newbie such as myself:


    <A HREF="/filename.pdf">


    I include some of my relevant code below, and the question
    is: how should I send a server-resident PDF file to the
    applet user's screen?

    -Ramon F. Herrera


    ----------------------------------------------
    This is the technique the applet uses to request
    anything from the server:

    URL url;
    URLConnection urlConn = null;
    DataOutputStream dos;
    DataInputStream dis;
    InputStream is;

    url = prepareServerCommand(true);

    try {
    urlConn = url.openConnection();
    }
    catch (IOException ex) {
    }

    urlConn.setDoInput(true);
    urlConn.setDoOutput(true);
    urlConn.setUseCaches(false);
    urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    String s = null;

    try {
    dos = new DataOutputStream(urlConn.getOutputStream());
    String message = "NEW_ITEM=1";
    dos.writeBytes(message);
    dos.flush();
    dos.close();

    is = url.openStream();
    BufferedReader d = new BufferedReader(new InputStreamReader(is));
    s = d.readLine();
    d.close();
    }
    catch (IOException ex1) {
    }

    done = 1;

    return (done);
    }
    Ramon F Herrera, Jul 7, 2003
    #1
    1. Advertising

  2. This is how to do it, Ramon:

    private void displayTheReport() {
    URL url = null;

    try {
    url = new URL("http://web.server.com/filename.pdf");
    }
    catch (MalformedURLException ex) {
    }
    AppletContext ac = getAppletContext();
    ac.showDocument(url);
    }

    -Ramon



    (Ramon F Herrera) wrote in message news:<>...
    > My Java applet collects some parameters from the user,
    > which are sent as arguments to the web server via GCI.
    > The server in turn receives the request, execs the
    > *.gci app which prepares a PDF report to the user's
    > specifications, end e-mails the report to a given e-mail
    > address.
    >
    > All the above is working well, and my question is about
    > a very common feature which I don't know how to implement
    > in Java: if the user clicks on a button, the PDF file should
    > be send to (stdout?) the screen for immediate viewing as
    > opposed to e-mailing.
    >
    > This feature is very easy to implement in HTML, even for
    > a complete HTML newbie such as myself:
    >
    >
    > <A HREF="/filename.pdf">
    >
    >
    > I include some of my relevant code below, and the question
    > is: how should I send a server-resident PDF file to the
    > applet user's screen?
    >
    > -Ramon F. Herrera
    >
    >
    Ramon F Herrera, Jul 9, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russell
    Replies:
    1
    Views:
    365
    Steve C. Orr [MVP, MCSD]
    Jan 21, 2004
  2. Krista
    Replies:
    3
    Views:
    2,302
    Andrew Thompson
    Sep 15, 2004
  3. Ricardo Pog
    Replies:
    1
    Views:
    396
    Austin Ziegler
    Mar 26, 2008
  4. Sean Nakasone
    Replies:
    1
    Views:
    338
    Farrel Lifson
    Apr 14, 2008
Loading...

Share This Page