At 10:05 AM 12/15/01 -0800, you wrote:
>Hey All,
>
>I am a bit confused in J2EE (and tomcat) concerning the best spot to do a 
>bunch of initializations, and other startup code.
>
>Now, in Coldfusion you have the Application.cfm file which gets run on 
>every request, thus you can load up the application scope (if
>its unitialized) or recycle it periodically with data/objects (which is 
>great for cache queues).
>
>In jsp, I would like to have a  jsp file run on initialization so that I 
>can offer that file as a jsp based application
>initialization file (using custom tags to load up the application scope 
>and even session and other goodies like internationalization
>bundles etc).
>
>It seems the best spot would be a ServletContext listener that would, on 
>startup, fire a request to the Application.jsp file ... but
>this does not seem possible given the ServletContextListener interface (or 
>is it)?
>
>In general, I haven't found much info on best practices for setting up the 
>initial state of an application.  If I wanted load up
>some JNDI entries on startup, where is the best place to do this (in a 
>ServletContextListener perhaps?) ?  And for some application
>attributes, same question.  And to initialize the session for a user?
>
>I really like the Coldfusion concept of the Application.cfm file since you 
>can do all your state checks there, and then all your
>scripts/servlets can expect the web application state to be well 
>managed.  Its also a great spot for loading in internationalization
>resource bundles.
>
>It would be even better to have a more fine grained Application.jsp file 
>that would fire on initialization and vice versa, and for a
>few other significant application events.  I don't particularly like 
>putting a lot of params in the web.xml file since this can
>complicate migrations and makes it a bit un-programmatic.  I also like 
>having simple custom tags loading the application and session
>scope so that you can glance at one script for the app and see what is in 
>those scopes by default, rather than having servlets doing
>their own thing and promoting decentralized scope processes.
>
>Any ideas?
>
>Thanks,
>John.

Hi, John,

I actually cannot tell what you are talking about.  You are not making 
sense to me.  But, here is a stab of helping.

Well, I don't know about ColdFusion, but the idea of a "startup" JSP file 
"application" initialization makes no sense in Java.  You could set 
application values with a JSP, but that is not what you want.

If when you startup a JSP/servlet container you want application parameters 
set, then you need to set them at the outset with a startup servlet.  Such 
servlets are commonly called "StartupServlet.class".  I have no idea why 
you don't like using web.xml to set the values of your initialization.  The 
idea of the web.xml is to promote "migrations" and "programmatic" 
behavior.  Why you think it is unsuccessful is less than clear to me.

Perhaps you would prefer to go further and use JNDI for 
initialization?  Application wide parameters can be set whenever you want 
to do so.

I suspect, but am not sure, that you have not looked at what JSP/servlets 
have to offer as yet.  If you have and I am missing the point, please 
accept my apologies and know that at least I am trying to help you.

Why do you think web.xml is such a bad idea?  That is not clear at all.

- micael




--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to