I'm working on a
servlet. In several places, if an error condition is detected, I want to forward to an
jsp page to display information about the error. The problem is that this error condition may be buried way down the call stack, and after forwarding, the servlet continues to execute code.
Here is the code of a trivial servlet that illustrates the problem.
When I run this, it forwards just fine to the jsp page but it prints out the line saying "
You should never see this". If I uncomment the "if (true) return;", the code works as expected; however, I may want to call fail() from way down the call stack and I can't simply return after each call to fail(). What I really want is a way to completely bail out of the servlet after forwarding. How do I do that?
[ April 11, 2006: Message edited by: Dan Tenenbaum ]