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
Thanks a Million!
What while loop are you talking about, and how is the servlet being accessed? Where is the Ctrl-C being entered? Your post is very short on details.
The while loop, I was referring to is in the Servlet Code.
The servlet is deployed on a TomCat.
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.
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.
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
Thanks a bunch !
Steven Rodeo wrote:
Nope the above code won't throw an exception.
This post isn't very helpful.
Is your code actually running inside a servlet?
Is it inside the doPost method?
If so, why are you declaring a ServletRequest on line one?
you should be using the one passed to the doPost method by the container.
Is all of this code wrapped in another try/catch block that deals with your exception or throws an IOException or ServletException?
It would be helpful if you posted all the code (if not for the entire servlet, than at least for the service method that you're overriding).
Tomcat will throw an exception if the client disconnects before the completion of the service method.