Estou com problemas no download de arquivos, não consigo baixá-los a caixa de diálogo é exibida o arquivo nao é baixado.
alguém poderia dar um help?
segue o código.
public ActionForward buscarLogomarca(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
Rede rede= (Rede) request.getSession().getAttribute("rede");
URL url = new URL("file://" + rede.getLogomarca());
InputStream in = url.openStream();
OutputStream out = response.getOutputStream();
response.setHeader("Content-disposition", "attachment; filename=arquivo.jpg");
// response.setContentType("image/jpeg");
int BUFFER_SIZE = 4096;
byte[] buf = new byte[BUFFER_SIZE];
int len;
while ((len = in.read(buf)) > 0)
out.write(in.read(buf));
in.close();
out.flush();
out.close();
return null;
}