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