javax.servlet.jsp.JspException: Connection reset by peer: socket write error

Hi,

Can any one help me solve this problem.

I am using a web based application developed using JSP , Struts, jdk1.4.1 and Tomcat 4.1 as server, it is a huge application. I have a process of loading the data from the excel sheet
and save it to the database, the excel sheet contains huge data.

In come cases not exactly in a series of steps when more than one person is using the
system from different places, to load the data i am getting "javax.servlet.jsp.JspException: Connection reset by peer: socket write error"

This vmi_load.jsp page where i am getting exception, accepts the excel file path to read the data the exception is rised when i press the submit button which try to load another java file. As i already mentioned alrady this application is developed using struts frame work don't kown if this is one of the proble for this exception.
 
This is the exact error what i am getting :

SEVERE  8/29/03 6:04:26 PM org.apache.jsp.vmi_load_jsp::Exception caught in vmi_
load.jsp:       Throwing exception: javax.servlet.jsp.JspException: Connection r
eset by peer: socket write error
javax.servlet.jsp.JspException: Connection reset by peer: socket write error
        at org.apache.struts.taglib.template.InsertTag.doEndTag(InsertTag.java:1
49)
        at org.apache.jsp.vmi_load_jsp._jspService(vmi_load_jsp.java:1282)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:204)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
95)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:684)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:432)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:356)
        at org.apache.struts.action.ActionServlet.processActionForward(ActionSer
vlet.java:1759)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:159
6)
        at org.apache.struts.action.SecureActionServlet.process(SecureActionServ
let.java:97)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:260)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
.java:246)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

        at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2415)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:180)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:170)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:172)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:174)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

        at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
3)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:432)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:386)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:534)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:530)
        at java.lang.Thread.run(Thread.java:536)

Waiting for the solution from the gurus and friends....

Regards
Anand
ewizzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kennethxuCommented:
The exception merely saying that the browser closed the tcp/ip connection to the server. usually after web browser send request to servet, it will keep the tcp/ip connection open and waiting for the response from server. it should only close the connection after it get entire response from server. But there is cases that browser closes connection:

1. timeout, browser thought the server is dead
2. user close the browser, hit the stop botton or back/forward button.
3. in some other cases browser will close the connection for some image files or browser find there is a cached page after it processes the header.

In you case, mostly like is case 1.

if you process take really long, you have 2 approach to solve you problem.

A. start a separate thread to process the data, let the jsp page return back to user and ask user to check back or keep refresh a status page.

B. during the process, keep sending some data, for example blank space to browser every 1 minute or so and flush it:
e.g.:
in the loop of processing data
  check if it is already 1 minute, if yes do
  out.print(" "); out.flush();
  ...
end of loop

let me know if you need more detail on either one.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kennethxuCommented:
BTW, you have too much open question, please close them:
http://www.experts-exchange.com/Web/Web_Languages/JSP/viewQuestionHistory.jsp?mid=758825
ewizzAuthor Commented:

We are not closing browser window or clicking on any other link.

I need a solution for the socket error. The page contains code for loading data from excel file and store it in database.

I donot know how to reduce this question.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

kennethxuCommented:
please read my comment again, solution was provided. I'm afraid I couldn't explain it better if you still don't understand.
cheekycjCommented:
kenneth is correct.  Most of the time this happens due to the user hitting stop/refresh or clicking on a link before your page finished loading.  We just catch the error and ignore it b/c its not a functionality error.

CJ
ewizzAuthor Commented:
The problem occurs only when another user concurrently accesses the same page. I guess there must be some problem with accessing database by the concurrent users.

Anyway we tried the suggested flush() method in our code but in vain.

Please advise.
KuldeepchaturvediCommented:
As I see it.. Connection reset can happen in two places in this application..........
One between Browser and Web server as Kenneth had said and another between Database and Webserver while uploading the data.....
As the question indicates that its happening on a concurrent use of the database I suspect its the second case here....
I am not a struts expert but I still suggest to post your database upload code for all of us to see if we can figure something out of it.

Regards
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: kennethxu {http:#9248049} & cheekycj {http:#9253801} & Kuldeepchaturvedi {http:#9259515}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.