public class DownloadsArquivos extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
protected void service(HttpServletRequest req, HttpServletResponse response)
throws ServletException,
IOException {
ServletOutputStream out = null;
out = response.getOutputStream();
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=" + arquivo + ".txt");
for(String linha: expArq.getImport(filtro)){
out.write(linha.getBytes());
}
out.flush();
out.close();
}
public void destroy() {
// TODO Auto-generated method stub
super.destroy();
}
}
tentei fazer isto no fim do servlet
mensagen = "Arquivo concluido";
//tentei este
req.getRequestDispatcher("ok.action?mensagen=" + mensagen).forward(req, response);
//depois este
response.sendRedirect("ok.action?mensagen=" + mensagen);
//e este tambem
PrintWriter out1 = response.getWriter();
out1.println(mensagen);