Okay, I've written a servlet, and in this servlet I throw a custom exception, "InvalidSiteException", however when throwing this, all it does it return my nice error message to the top of the page, then continue execution of the servlet. How would I go about halting the execution of the servlet after the execption is thrown, cought, and error is displayed. What it does: "The siteid (s=2) does not exist on our servers. The page HTML continues to load and display after the exception being thrown and cought." What I want: "The siteid (s=2) does not exist on our servers." ---- Basically, for the servlet execution, output, etc... to stop after the error message. I want it to be fatal versus like a generalized message. Thanks in advance.
Hrm, this seems to work... Set the method return type to String, and then in the catch return null; after the error is sent. [ May 15, 2003: Message edited by: Charles OBrien ]
Author and all-around good cowpoke
Joined: Mar 22, 2000
All thats necessary to stop the remainder of the page being written is to close the output stream and return from your doGet or whatever. You should be able to: 1. response.resetBuffer() to discard previous output. You may have to increase the buffer size to ensure that none has been sent already. 2. write your custom error msg 3. close the output stream 4. return