Originally posted by Mike Curwen:
[B]Right, I misunderstood. I didn't realize it was a seperate Java standalone program that gets the errors. This is the program you want to leave, not the servlet.
I still have to learn the difference between a servelt and a standalone program (this is plain ignorance, nothing else)...
Option One
==========
System.exit(1) can sometimes be like "GoTo End". You can pepper them all over your code, and it's a easy way to write a program. So one option, instead of using System.exit(1), you can re-write those parts of your code, so that they 'naturally' exit the program on an error condition. It would probably involve a lot of if/else if/else blocks.
Right on the money: "a lot" are the key words on the above quote.
If an error occurs I could easly set the error bean.
But then again I would have to leave the method and after leaving it, allready on higher context, I would have to check again if an error occured. Since there was an error I would have to leave for a higher context and so on...
On a large code (and belive me, mine is large) this would mean having to insert hundreds of ifs/elses.
This is actually what I am trying hard to avoid.
Option Two
==========
A second option.. and I haven't really thought this through or tried it... But if you write your program in such a way that one super method, sort of like this:
Then if you don't ever catch any MyBadExceptions, they will eventually cause the program to end abnormally. And in all the times that I've been testing and debugging servlets that end horribly and abnormally with large stack traces, I've never noticed that it's brought down the whole Tomcat instance. Maybe you can do this.
All I can say about this is that I have not tried it.
No doubt the idea is interesting.
Seems like a path to explore. I�ll run some simple tests and post the results here.
Third Option
============
The third option, and I have tried to look this up, but can't find it... (perhaps because it's not possible). Maybe there is a way to specify when you are executing a java program to ensure (with a switch) that the new running instance is in its own JVM.
This is the option I prefer.
If it�s possible it�s the way to go.
The actual code implementation of this is clean and it requires only creating a new bean to store the errors.
I think you are correct when you say that this is not possible but I think it�s worth spending a bit of time making shure things are really like this.
As another post to the JavaRanch seems to say, each invocation of the 'java' command at a console window should start its own JVM. http://www.javaranch.com/ubb/Forum34/HTML/000621.html [/B]
Consider Paul's rocket mass heater. |