struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishore Senji <kishorese...@gmail.com>
Subject Re: <html:errors> not working when sending a file to client with struts.
Date Thu, 13 Oct 2005 23:25:20 GMT
> response.setContentType("application/zip");
> response.setHeader("Content-Disposition", "attachment; filename=" +
> zipFileName);
> response.setContentLength((int)tempCSVFile.length());
> BufferedInputStream bufferedInput = new BufferedInputStream(new
> FileInputStream(tempCSVFile));
> BufferedOutputStream bufferedOutput = new BufferedOutputStream(
> response.getOutputStream());
>
> while((leftToRead = bufferedInput.read(buffer)) != -1) {
> bufferedOutput.write(buffer, 0, leftToRead);
> }
>
> bufferedInput.close();
> bufferedOutput.flush();
> bufferedOutput.close ();
>
> if(!errors.isEmpty()) {
> saveErrors(request, errors);
> return(mapping.findForward("fail"));
> }
>
> return (mapping.findForward("success"));


I don't think it's anything to do with Struts. You just set the
content-length header, which tells the servlet container how much the
response body length would be. If you try to write more stuff into it, I'm
not sure it would get written to the response.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message