Hello:
I'm trying to send a PDF file with a Servlet. My Application Server is JRUN.
When a run this servlet, I received the message: "Connection reset by peer:
Socket write error."
Any help/advice would be so much appreciated.
Javier
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite(Native Method)
at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:112)
at allaire.jrun.ServletOut.write(ServletConnection.java:526)
at
java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:126)
at allaire.jrun.servlet.ServletBAOS.commit(ServletBAOS.java:163)
at allaire.jrun.servlet.ServletBAOS.commit(ServletBAOS.java:140)
at
allaire.jrun.servlet.JRunOutputStream.write(JRunOutputStream.java:100)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:112)
at Clientes.ClientSrv.performTask(ClientSrv.java:126)
at Clientes.ClientSrv.doPost(ClientSrv.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
at
allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34
)
at allaire.jrun.servlet.Invoker.service(Invoker.java:84)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
at
allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.jav
a:88)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
at allaire.jrun.http.WebEndpoint.run(WebEndpoint.java:107)
at allaire.jrun.ThreadPool.run(ThreadPool.java:267)
at allaire.jrun.WorkerThread.run(WorkerThread.java:74)
This is the code of the servlet:
public void doPost(HttpServletRequest request, HttpServletResponse
response)
{
//---------------------------------------------------------------
// Set the output data's mime type
//---------------------------------------------------------------
response.setContentType( "application/pdf" ); // MIME type for pdf
doc
//------------------------------------------------------------
// Content-disposition header - don't open in browser and
// set the "Save As..." filename.
// *There is reportedly a bug in IE4.0 which ignores this...
//------------------------------------------------------------
response.setHeader("Content-disposition","attachment; filename=" +
"Example.pdf" );
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
ServletOutputStream out = response.getOutputStream ();
// Use Buffered Stream for reading/writing.
bis = new BufferedInputStream(new
FileInputStream("d:\\file.pdf"));
bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff, 0, bytesRead);
}
}
catch (Exception theException)
{
theException.printStackTrace();
}
}
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets