Hi , In conversation with an ApplicationServer administrator , I came across the fact , that servlets should not be marked as a startup servlet (a servlet whose init() method is invoked by the application server when it comes up).The reason being , that an improperly written (read as poor exception handling) servlet might cause the servlet engine to crash .. Is this true ?? Is there an alternative to this ? Property files , I gather can be read by resource bundles , how about the Java objects which have to shared across servlets and JSP , runnning in that virtual machine ? For example , I initialize a database connection pool in my startup servlet and write the reference of that in to the contetx,so that the other entities would have access to that . In the absence of a startup servlet , how should I go about implementing it ? Could some one provide a solution for this from the architectural perspective ? Regards Rayan
Short of calling some poorly-coded JNI methods in your init() method, that's sheer horse hockey. There is no way that this could happen. Your system administrator is either repeating things he's heard (without substantiation) or making this up... Kyle ------------------ Kyle Brown, Author of Enterprise Java (tm) Programming with IBM Websphere See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
I suppose someone COULD have created an appserver that was that feeble, but if I found mine doing that, I'd quickly be looking for a new appserver. First of all, if a servlet was going to crash the appserver, whether it was called on startup or later isn't going to matter much -- any I'd rather have it die while people are still paying attention (at the startup console). Secondly, you'd be losing valuable functionality. A startup servlet is an ideal place to put stuff that is required by the app on a global basis, such as initializing database and pooling subsystems. This assertion sounds to me like some wisdom carried over from something like IIS, where compiled code is invoked directly from the main thread of the appserver and exception handling isn't a major product feature.
An IDE is no substitute for an Intelligent Developer.
Joined: Nov 18, 2001
Thanks a lot for your reply . I did discuss this others , and we would be going the "Startup servlets" way . Thanks again
How does one mark a servlet as a "startup" servlet? I'd heard that WebLogic could do this, but is there a cross-platform way to do this on any J2EE app server (servlet container)? Forgive my ignorance, I'm still learning... Thanks!
CJP (Certifiable Java Programmer), AMSE (Anti-Microsoft Software Engineer)
Author of Posts in the Saloon
It's in the spec, any 2.2 compliant servlet container should be able to do it. Include < load-on-startup >order< /load-on-startup > as (I think) the last tag within the < servlet > tag in WEB-INF/web.xml. The order is a number that determines, well, the order in which the servlets will be started. Use a different number for each servlet, some application servers don't like it if different servlets get the same number. [ Almost. The last tag inside < servlet > except for the < security-role-ref > tags. ] - Peter [This message has been edited by Peter den Haan (edited November 23, 2001).]