Sending a PDF file from applet to screen?

  • Thread starter Ramon F Herrera
  • Start date
R

Ramon F Herrera

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);
}
 
R

Ramon F Herrera

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top