Originally posted by Ernest Friedman-Hill:
Just get a better application server!
In modern JVMs, for a class to be unloaded its ClassLoader must be garbage collected; for that to happen, all objects of all classes loaded by the ClassLoader must be unreachable. The way a decent application server manages class reloading is by loading applications each in their own ClassLoader, and when an application is to be unloaded, it simply discards the ClassLoader and creates a new one, which can load new copies of the classes, allowing the old ones to be collected.
I hope you understand why the scenario you describe is not possible -- unless your servlet itself implements an entire application server, and loads and reloads applications by itself!
Originally posted by Ben Souther:
you may want to poke around in Tomcat's classloader source code to see how they're doing this.
you change a JSP, Jasper regenerates the servlet code, the servlet gets compiled, and then gets loaded
The main servlet would delegate all of its work to other classes that it loaded itself through its own ClassLoader. When it needed to reload the classes, it could simply create a new ClassLoader and do so.
Originally posted by Kaushik Sathupadi:
Pls. don't ask me to re-structre the entrie application for this. The designers would kill me.
I think in that case you're out of luck. Have you looked at just getting a better app server?
We'd prefer that you keep the conversation here.