I am working with following code....
In this I am getting a problem.According to me when it execute the sendRedirect() and goes on other page it should not print the "After catch" statement but it is printing it. Why is it so?
[This message has been edited by Gurpreet Sachdeva (edited October 24, 2001).]
Therefore you need soething like
This is just a sample, I am NOT telling you to have a return inside a catch block, this is a really bad idea!
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
Originally posted by Mike Curwen:
The only reason this is completely fine, is that the result of the code after the sendRedirect() in no way makes a difference to the application. ie: if it throws an error, it is buried and ignored anyways. Also, as a business rule of the app, if the operation does not complete successfully in any other way, the client is not notified. Pretty crazy, but there it is.
Not for the faint-of-heart though.
I'm reviewing an app at the moment that has bunches and bunches of stuff like this (presentation sent then business logic continues) and it is very unstable in their case.
If the presentation starts (but does not complete) and some more business logic gets going, then the client recieves the partial page then clicks another link, when the original code tries to write more presentation, an Exception is thrown.
This is also complicated in their case since they are using a MVC architecture with a global controller and it maintains client state (and what step they are at) and gets confused very easy.
Just saying: it's possible, but I personally wouldn't do it.