Does anybody know how, in a jsp or servlet, to forcibly close the http connection so the client (browser) shows some sort of page saying the server closed the connection?
For those of you who will want to know why I need to do this, I'll tell you. We have a file upload page and we want to set a maximum limit. I have already figured out how to do this with commons fileUpload, and that works fine, but after I detect the fact that the user is sending us way too much data, I want to close the connection. It just saves bandwidth charges this way.
I've tried request.getInputStream().close(), but that doesn't seem to do it.
Originally posted by Ben Souther: The return; statement doesn't do it for you?
No it doesn't. When I start uploading a large file, the code quickly detects that it has exceeded the maximum limit (if the maximum limit is small enough). I can even write a note to the log saying that the limit has been reached and we should close the connection, but the complete file still gets uploaded the whole way even long after we don't want to listen any more. I want to get a hold of the tcp socket and close that connection, or tell someone else to please close it for me because I'm not going to listen any more.