File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes get Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "get "java.net.SocketException: socket closed", even if i am using HTTP connection" Watch "get "java.net.SocketException: socket closed", even if i am using HTTP connection" New topic
Author

get "java.net.SocketException: socket closed", even if i am using HTTP connection

Dupont Girard
Greenhorn

Joined: Mar 21, 2011
Posts: 24
Hi, I encountered an exception by executing this code:





The line of code that make this exception is: "int taille = input.read(mot);", if i copy it into the Servlet part, it works well, but i think that the Servlet shall not be in charge of these.

The exception is:
"java.net.SocketException: socket closed" even if i am not using Sockets, but HTTP.
I think that the "input" in RequestStatement's method contains no value "null"

Help me



Chris Beckey
Ranch Hand

Joined: Jun 09, 2006
Posts: 116

I believe that what is happening is that the RequestStatement thread is not finishing by the time the HTTP thread, which the servlet code is running on is finishing and closing the connection.
In this case I don't see a reason to start the second thread because you would have to synchronize and wait for it to complete before returning from the servlets doXXX method anyway. It will also complicate error handling, redirection and including content should that ever become necessary.
Dupont Girard
Greenhorn

Joined: Mar 21, 2011
Posts: 24
Thanks Chris of your answer. You're right, i just put a join() on my thread and it works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get "java.net.SocketException: socket closed", even if i am using HTTP connection
 
Similar Threads
Creating a Pipe that connects 2 sockets
Problem in wrtitng JAR File
Sending a file over socket
Not Sure
Error in calling shutDownInput and shutDownOutput