Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/11/2006, 10:05
Avatar de stock
stock
 
Fecha de Ingreso: junio-2004
Ubicación: Monterrey NL
Mensajes: 2.390
Antigüedad: 19 años, 10 meses
Puntos: 53
pues es lo mismo que ahces en PHP, modificar las cabeceras y leer el fichero

algo asi:
Código PHP:
<!--contents of download.jsp-->
<%@ 
page import="java.util.*,java.io.*"%>

<%
    
//lees el archivo claro que por aqui aplicas algunos filtros de seguridad y esas cosas
    
    
File f = new File ("c:/fop/mypdf/" request.getParameter("file") );
    
//aqui seleccionas el content type (puede ser excel/word/powerpoint etc..)
    
response.setContentType ("application/pdf");
    
//aqui seleccionas el nombre con el cual el usuario lo recibira
    
response.setHeader ("Content-Disposition""attachment; filename=\"LicenseAgreement.pdf\"");
    
    
//optenemos el nombre del archivo
    
String name f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
    
//leemos el archivo para mandarselo al cliente
    
        
InputStream in = new FileInputStream(f);
        
ServletOutputStream outs response.getOutputStream();
        
        
        
int bit 256;
        
int i 0;


            try {


                    while ((
bit) >= 0) {
                        
bit in.read();
                        
outs.write(bit);
                    }
                    
//System.out.println("" +bit);


                    
} catch (IOException ioe) {
                        
ioe.printStackTrace(System.out);
                    }

                    
outs.flush();
                    
outs.close();
                    
in.close();    
            %> 
have funnnnnn