This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
As it says... I want to catch every exception inside a catch on a Filter I wrote, this exception will be store temporally in a session bean and treated in a differente way than usual.
My filter ended up looking like this...
This keeps what I assume is some error flag or something as true but does not raise the 500 error code to the container thus avoiding the page redirection. Exactly what I needed to do.
Using Tomcat 6x within Eclipse works ok.
But when I run the same Tomcat installation as standalone my application (wich was previously packaged as a WAR file and deployed in the webapps directory) redirects to the 500 error page.
It's really odd to me because, as I said, i'm using the same Tomcat installation.
Any ideas of what the cause could be?
Is there a difference between the way Eclipse starts the tomcat and the way it starts by executing the "run.bat"?
Is there another way to let the servlet know that an exception must not be raised as a 500 error code?
Would that other way keep that internal error flag used by the a4j:queue JSF component to raise the "onerror" event?
There seems to be a fundamental flaw in your concept.
"doFilter" percolates through the filters until it reaches what is, in effect, the final filter: sending the request to the target servlet, then returning the response.
If the exception should occur before a response is generated, you only have half of the request/response cycle accounted for. You really do need something better than a sendRedirect(null) to allow for that.
As far as frameworks go, yes, the classpaths inside Eclipse do vary over running stand-alone, and even more so considering that if you're using WTP it's a flawed implementation of Tomcat. I have seen odd behavior while debugging filters.
An IDE is no substitute for an Intelligent Developer.