Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.net.SocketException: Connection reset by peer: socket write error

807580Aug 11 2009 — edited Aug 16 2009
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2009
Added on Aug 11 2009
27 comments
21,123 views