I did not understand why u cannot let one servlet in particular to run first(by giving highest load-on-start value in DD -in that case the servlet gets loaded and initialized even before the 1st request comes in) and put code inside that servlet to set servletcontext attributes(for entire web app)??HFS doesnt state why it is a wrong approach(ref page-164)
Howdy -- good question. While you can certainly do it *technically*, I think it's more of a design approach that's the problem--that you would have a dependency on configuring that servlet to load first, and it's kind of an arbitrary way to initialize those things. If your application changes, you'd always have to remember to have one servlet configured to do that, and from an OO standpoint, it might not be the most cohesive to pick one servlet and designate it as The One To Do That Lookup Work. Whereas a listener might make a better design choice...
So, you're right, Sanday, that you could do this. It's a design issue that we were complaining about, but we should have been more clear in explaining WHY we said it like that.
posted 14 years ago
one more question--page 596 HFS-no dumb questions-it says u can save resources by not loading servlets that are rarely used in advance..but even if 1 client makes a request that results in loading of a particular servlet which is very rarely used it stays loaded till the web app goes down....isn't it a disadvantage???..i mean wouldn't it have been good had there been someway to unload the servlet without bringing the app down