public void doGet(HttpServletRequest request, HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException{
Long id = Long.valueOf(request.getParameter("id"));
FotoDTO foto = ServiceFactory.getInstance().getPropiedadesSiniestradasService().getFoto(id);
// Get the absolute path of the image
ServletContext sc = getServletContext();
String filename =foto.getNombre();
// Get the MIME type of the image
String mimeType = sc.getMimeType(filename);
if (mimeType == null) {
sc.log("No se encuantra el MIME type de "+filename);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
resp.setContentType(mimeType);
resp.setContentLength(foto.getDatos().length);
OutputStream out = resp.getOutputStream();
out.write(foto.getDatos(), 0, foto.getDatos().length);
out.close();
}