jsp y pdf

EDGAR
16 de Enero del 2004
Alguien me prodria ayudar tengo que imprimir un jsp y lo quiero abrir como pdf para que lo puedan imprimir logicamente de lado del cliente necesitan el read pero que hago para que se abra como pdf ? graciasss

BURGALES
16 de Enero del 2004
Prueba esto:

<%@ page contentType="application/octet-stream" buffer="8kb"%>
<%
try {
if (out != null && out.getBufferSize() != 0) {
out.clearBuffer();
}
String file = request.getParameter("file");
String fichero = "/usr/iplanet2/ias64cat/ias/APPS/procamapp/" + file;
if(fichero!=null && fichero.trim().length()>0) {
String auxFile = fichero.trim();
int pos = auxFile.indexOf("/");
if(pos>0 && pos<(auxFile.length()+1)) {
auxFile=auxFile.substring(pos+1);
}
try {
java.io.FileInputStream fis = new java.io.FileInputStream(fichero);
int n=fis.available(); //Returns the number of bytes that can be read from this file input stream without blocking.
java.io.OutputStream outs = response.getOutputStream();
response.setHeader("Content-Disposition","inline; filename=" + file);
response.setContentLength(n);
byte[] PDFDocument = new byte[n];
fis.read(PDFDocument); //Reads up to b.length bytes of data from this input stream into an array of bytes
outs.write(PDFDocument); //Writes b.length bytes from the specified byte array to this output stream.
outs.flush();
fis.close(); //Closes this file input stream and releases any system resources associated with the stream.
outs.close(); //Closes this output stream and releases any system resources associated with this stream
return;
} catch (java.io.IOException ioe) {
System.out.println("*** "+getClass().getName()+". IOException: "+ioe);
}
}
} catch (Exception e) {}
%>



Aupa!
Burgales.