PrintWriter out;
private OutputStreamWriter osw;
if (response != null) {
response.setContentType(contentType);
response.setCharacterEncoding("WINDOWS-932");
response.setHeader("Content-Disposition",
"attachment; filename="
+ URLEncoder.encode(fileName, "WINDOWS-932"));
osw = new OutputStreamWriter(response.getOutputStream());
out = new PrintWriter(osw,true);
}
InputStream in = new ByteArrayInputStream(strData.toString().getBytes("WINDOWS-932"));
ServletOutputStream sosout = response.getOutputStream();
try {
byte[] inputByte = strData.toString().getBytes("WINDOWS-932");
byte[] outputByte = new byte[inputByte.length];
// copy binary contect to output stream
while (in.read(outputByte, 0, inputByte.length) != -1) {
sosout.write(outputByte, 0, inputByte.length);
}
I am using this code to download csv file. Using this code i got output in the response. I got this code in some site and i dont know what this code is doing. I also got the below mentioned exception. How to resolve this?
... 27 more
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:327)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:293)
at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:97)
at com.ccvp.vois.action.DownloadCsv.download(DownloadCsv.java:272)
at com.ccvp.vois.action.DownloadCsv.service(DownloadCsv.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.ccvp.vois.se
-vignesh