forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							40 lines
						
					
					
						
							1.1 KiB
						
					
					
				
			
		
		
	
	
							40 lines
						
					
					
						
							1.1 KiB
						
					
					
				| package com.evolute.siprp.pagina;
 | |
| 
 | |
| 
 | |
| import java.io.IOException;
 | |
| import java.io.OutputStream;
 | |
| import java.sql.Connection;
 | |
| import java.sql.DriverManager;
 | |
| import java.sql.PreparedStatement;
 | |
| import java.sql.ResultSet;
 | |
| import java.sql.SQLException;
 | |
| 
 | |
| import javax.servlet.http.HttpServletRequest;
 | |
| import javax.servlet.http.HttpServletResponse;
 | |
| 
 | |
| 
 | |
| public class doGetFicheiro extends siprpServlet
 | |
| {	
 | |
| 	private static final long serialVersionUID = 1L;
 | |
| 	
 | |
| 	public doGetFicheiro(HttpServletRequest req, HttpServletResponse res, String query) throws IOException, SQLException, ClassNotFoundException
 | |
| 	{
 | |
| 		Class.forName( bdDriver );
 | |
| 		Connection con = DriverManager.getConnection( bdLocalUrl, bdLocalUsername, bdLocalPassword );
 | |
| 		res.addHeader( "Content-disposition", "attachment;filename=\"" + query + "\"" );
 | |
| 		res.setContentType("application/octet-stream");
 | |
| 		OutputStream os = res.getOutputStream();
 | |
| 		PreparedStatement ps = con.prepareStatement("SELECT file_data FROM fil_file where name='" + query + "'");
 | |
| 		ResultSet rs = ps.executeQuery();
 | |
| 		if(rs != null)
 | |
| 		{
 | |
| 			while(rs.next())
 | |
| 			{
 | |
| 				byte[] b = rs.getBytes(1);
 | |
| 				os.write(b);
 | |
| 			}			
 | |
| 		}
 | |
| 		os.flush();
 | |
| 		os.close();
 | |
| 	}
 | |
| } |