The following servlet handles a POST request. The following servlet accepts an input file, and writes this to a DISK. The problem is when the user / Client / UI which is talking to this servlet
issues a CTRL-C ( SIGINT ), the servlet seems to ignore it, it won't throw an exception. Don't know how to handle such a scenario. How does one handles this situation
A stand alone application (Jar file) is trying to access this servlet via an URL some thing like this.( this is run on my local machine )
For instance when the uploaded FileName is large, it might take a very long timeto upload. Consequently the user issues a Ctrl-C
causing the while loop (in the servlet code ) to exit. I don't want this to happen, I rather fail when the Ctrl-C is issued, and throw an
Exception back to the client.
That's not what I asked. How is the application accessing the servlet? Not how is someone running the application.
If the app is accessing the servlet using an HTTP connection, the same applies. The servlet is on the other end of the connection and cannot respond to things like a Ctrl-C that it know nothing about. All it knows is that for some reason the client stopped sending data in the middle of the upload, or that the connection for the response is closed, or whatever happens to the connection when the client is aborted. There's is no way to make it react to a Ctrl-C on the other end of the connection.
Joined: Mar 06, 2008
All it knows is that for some reason the client stopped sending data in the middle of the upload, or that the connection for the response is closed, or whatever happens to the connection when the client is aborted
Thank you!!!...... I think you solved my problem, is there a way to figure out from the InputStream, what I am expecting some thing like how big a stream its going to be ?. Coz that way I can throw an Exception once the connection fails
You mean in that servlet code you posted? It's already going to throw an exception if it can't read the whole input stream because the client disconnected. There's no need for you to try to duplicate that.