Re: [OT] looking for a method that will be called on application startup
Thanks guys! That was exactly what I was looking for - and it works like magic. Great, thanks again! Arne Robert Taylor wrote: The ServletContextListener does exactly what you want. When the web application starts the ServletContextListener.contextInitialized() is invoked passing you ServletContextEvent which contains the ServletContext. These are guaranteed to be invoked before the web application can process any requests. It's simply an interface which you implement (2 methods) then define in your web.xml file. For more information refer to the Servlet 2.3 spec or higher. http://java.sun.com/aboutJava/communityprocess/first/jsr053/index.html robert -Original Message- From: Otávio Augusto [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 03, 2004 8:39 AM To: Struts Users Mailing List Subject: Re: [OT] looking for a method that will be called on application startup do you mean a single implementation of a servlet, with methods which fit each developer needs, and declaring this servlet in the appropriate place in the web.xml file? doesn't this servlet need anything special? I ask that because I've never made a ContextListener, and I also need a "first time verification" in my app. Thanks Otávio Augusto On Mon, 02 Feb 2004 14:07:47 +0100 Marcel Schepers <[EMAIL PROTECTED]> wrote: Hi Arne, A solution could be create an initialization servlet. Include that servlet in your web.xml and make sure you provide a parameter. Marcel On Mon, 2004-02-02 at 13:59, Arne Brutschy wrote: hi, I'm looking for a method/hook/whatever that will be called from tomcat at application startup. I want to use it to put all my init-stuff (as configuration reading) into it. At the moment, my authentication filter looks for the presence of these objects in application scope, and if they are not found, they will be created. Is there another way to do this more nicly? Regards, Arne - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] looking for a method that will be called on application startup
The ServletContextListener does exactly what you want. When the web application starts the ServletContextListener.contextInitialized() is invoked passing you ServletContextEvent which contains the ServletContext. These are guaranteed to be invoked before the web application can process any requests. It's simply an interface which you implement (2 methods) then define in your web.xml file. For more information refer to the Servlet 2.3 spec or higher. http://java.sun.com/aboutJava/communityprocess/first/jsr053/index.html robert > -Original Message- > From: Otávio Augusto [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 03, 2004 8:39 AM > To: Struts Users Mailing List > Subject: Re: [OT] looking for a method that will be called on > application startup > > > do you mean a single implementation of a servlet, with methods > which fit each developer needs, and declaring this servlet in the > appropriate place in the web.xml file? doesn't this servlet need > anything special? I ask that because I've never made a > ContextListener, and I also need a "first time verification" in my app. > > Thanks > > Otávio Augusto > > On Mon, 02 Feb 2004 14:07:47 +0100 > Marcel Schepers <[EMAIL PROTECTED]> wrote: > > > Hi Arne, > > > > A solution could be create an initialization servlet. Include that > > servlet in your web.xml and make sure you provide a > > parameter. > > > > Marcel > > > > On Mon, 2004-02-02 at 13:59, Arne Brutschy wrote: > > > hi, > > > > > > I'm looking for a method/hook/whatever that will be called > from tomcat > > > at application startup. I want to use it to put all my init-stuff (as > > > configuration reading) into it. > > > > > > At the moment, my authentication filter looks for the > presence of these > > > objects in application scope, and if they are not found, they will be > > > created. > > > > > > Is there another way to do this more nicly? > > > > > > Regards, > > > Arne > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] looking for a method that will be called on application startup
do you mean a single implementation of a servlet, with methods which fit each developer needs, and declaring this servlet in the appropriate place in the web.xml file? doesn't this servlet need anything special? I ask that because I've never made a ContextListener, and I also need a "first time verification" in my app. Thanks Otávio Augusto On Mon, 02 Feb 2004 14:07:47 +0100 Marcel Schepers <[EMAIL PROTECTED]> wrote: > Hi Arne, > > A solution could be create an initialization servlet. Include that > servlet in your web.xml and make sure you provide a > parameter. > > Marcel > > On Mon, 2004-02-02 at 13:59, Arne Brutschy wrote: > > hi, > > > > I'm looking for a method/hook/whatever that will be called from tomcat > > at application startup. I want to use it to put all my init-stuff (as > > configuration reading) into it. > > > > At the moment, my authentication filter looks for the presence of these > > objects in application scope, and if they are not found, they will be > > created. > > > > Is there another way to do this more nicly? > > > > Regards, > > Arne > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] looking for a method that will be called on application startup
Hi Arne, A solution could be create an initialization servlet. Include that servlet in your web.xml and make sure you provide a parameter. Marcel On Mon, 2004-02-02 at 13:59, Arne Brutschy wrote: > hi, > > I'm looking for a method/hook/whatever that will be called from tomcat > at application startup. I want to use it to put all my init-stuff (as > configuration reading) into it. > > At the moment, my authentication filter looks for the presence of these > objects in application scope, and if they are not found, they will be > created. > > Is there another way to do this more nicly? > > Regards, > Arne > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] looking for a method that will be called on application startup
javax.servlet.ServletContextListener robert > -Original Message- > From: Arne Brutschy [mailto:[EMAIL PROTECTED] > Sent: Monday, February 02, 2004 8:00 AM > To: Struts Users Mailing List > Subject: [OT] looking for a method that will be called on application > startup > > > hi, > > I'm looking for a method/hook/whatever that will be called from tomcat > at application startup. I want to use it to put all my init-stuff (as > configuration reading) into it. > > At the moment, my authentication filter looks for the presence of these > objects in application scope, and if they are not found, they will be > created. > > Is there another way to do this more nicly? > > Regards, > Arne > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] looking for a method that will be called on application startup
hi, I'm looking for a method/hook/whatever that will be called from tomcat at application startup. I want to use it to put all my init-stuff (as configuration reading) into it. At the moment, my authentication filter looks for the presence of these objects in application scope, and if they are not found, they will be created. Is there another way to do this more nicly? Regards, Arne - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!
(Sorry for not replying till now. Been out of the office for a couple of days) It sounds like what you need to do would be to implement a struts PlugIn that reads the initial values from the database and creates beans containing this information. (These beans could in fact be instances of the ActionForm class they are intended as default values for). You store these default value beans in the servlet context. You will still need to copy the properties from these beans to the actual ActionForm that you are using however, and you only wish to do this once (after the form is created). The logical place to do this would be in the action that you go through before forwarding to the JSP for the first time. (Its considered best to always go through an action first and not have hyperlinks that go directly to .jsp files. Indeed most struts developers will hide the jsps under WEB-INF to stop them being accessible without first hitting an action). You may wish to make use of BeanUtils.copyProperties() method to simplify this step. Its javadoc is here: http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils /BeanUtils.html Since your copying from the beans you created at startup in the plugin, no extra db calls are involved so there wont be an efficiency issue. The other place I mentioned you could initialise the values in the new actionform instance was in the reset() method. Struts will call this method after instantiating the form instance and before populating it. (Im not sure if it calls it when the form tag causes an instance to be instantiated - but it will get called if its an action you are hitting). You could set a private flag in the ActionForm to keep track of whether this is the first time it is reset or not, and if it is, have code in the reset method look up the default values from the beans in the servlet context. If not the first time, then just do the normal reset type stuff. This however is not as good a solution as simply copying the properties in the action before going to the view. -Original Message- From: Curtney Jacobs [mailto:[EMAIL PROTECTED] Sent: Tuesday, 12 August 2003 00:39 To: Struts Users Mailing List Subject: Re: UPON APPLICATION STARTUP Thanks Nathan, Andrew. I am sorry that my earliler post was not specific and a little bit on the "sassy" side. Yes. My forms are session mapped forms and I will be getting the default values from my database. Andrew, the reason why I decided not use an action to load the default values in the forms is that this would be a query to the database *everytime*. Since, theses default values are static (will never change), I thought it makes more sense to load then upon application startup and have it within the current session. Oops, they should span accross multiple sessions, therefore, as you and Nathan suggested they should be put within the servlet context. Andrew, can you elaborate a littile bit more on the ActionForm reset issue that you mentioned? Thanks. _CJ On Sunday 10 August 2003 11:08 pm, Andrew Hill wrote: > Yeh alright mate. Keep ya hair on and enough with the shouting already! > > Since the forms are only instantiated when a request for that mapping comes > in its gonna be kinda hard to prepopulate values on them cos they dont > exist yet. Indeed unless you are using session mapped forms (such as for a > multipage wizard or such like) the form is only going to exist for the > scope of the request. > > Now Im assuming that you need to read these default values from somewhere > (which must be why you dont just slap em into the form constructors > directly). Since they dont change while the app is running (another > assumption your post didnt bother clarifying) your best bet would be to > read them into some kind of config objects (perhaps even a 'prototype' > instance of the forms in question) and store these in the servlet context. > Implement a struts plugin to do this at startup time. > > You could initialise the values in the form instance from these config > objects in the reset method. Dont forget to do this only on the first reset > (or you will overwite input). > > I reckon you would be best off doing as you were advised and copying the > defaults into the form in an action though rather than overloading the > reset method for this purpose. > > As for the lists of selectable choices in things such as drop downs - that > would best be left as shared beans in servlet scope (like Nathan says in > his reply to your post) - you would only want to copy values into the form > instance for defaults for stuff, as you can have your tags access the > shared beans directly for such tasks as rendering options in selects... > > > -Original Message- > From: Curtney Jacobs [mailto:[EMAIL PROTECTED] > Sent: Monday, 11 August 2003 13:46 > To: Struts Users Ma
RE: UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!
Yeh alright mate. Keep ya hair on and enough with the shouting already! Since the forms are only instantiated when a request for that mapping comes in its gonna be kinda hard to prepopulate values on them cos they dont exist yet. Indeed unless you are using session mapped forms (such as for a multipage wizard or such like) the form is only going to exist for the scope of the request. Now Im assuming that you need to read these default values from somewhere (which must be why you dont just slap em into the form constructors directly). Since they dont change while the app is running (another assumption your post didnt bother clarifying) your best bet would be to read them into some kind of config objects (perhaps even a 'prototype' instance of the forms in question) and store these in the servlet context. Implement a struts plugin to do this at startup time. You could initialise the values in the form instance from these config objects in the reset method. Dont forget to do this only on the first reset (or you will overwite input). I reckon you would be best off doing as you were advised and copying the defaults into the form in an action though rather than overloading the reset method for this purpose. As for the lists of selectable choices in things such as drop downs - that would best be left as shared beans in servlet scope (like Nathan says in his reply to your post) - you would only want to copy values into the form instance for defaults for stuff, as you can have your tags access the shared beans directly for such tasks as rendering options in selects... -Original Message- From: Curtney Jacobs [mailto:[EMAIL PROTECTED] Sent: Monday, 11 August 2003 13:46 To: Struts Users Mailing List Subject: UPON APPLICATION STARTUP Greetings! I would like to load default values in my forms upon application startup. Is this possible with STRUTS? Seriously, is this possible with STRUTS? If not, I will have to look some where else for this. Many of my forms have drop down list that enables the user to choose the appropriate values. It would be nice that UPON APPLICATION STARTUP forms that need default values are automatically populated with said values. I am aware that I can call an action that can prepopulate my forms with those values. However, it seems tedious to always call an action to populate a form with default values. Has anyone done this before, if so, I would greatly appreciate some assistance. This is like the upteen post concerning this. I find it hard that no one else needs this or has done this. Regards, Curtney - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Calling A default Action Upon Application Startup
Greetings Carlos. Thanks for replying. Yes. I can populate a form that way. However, it wouldn't quite give me what I want. For instance, as the application is initially loaded there should be default values already in the forms; this should be done prior to any user action. I like your one action approach. Is there a way to call this action as the application is initially loaded. Again, no user interaction should trigger this action class. Thanks, Curtney On Monday 04 August 2003 05:09 pm, Aguirre Carlos Federico wrote: > if you need to populate a form, you can do in one action > and then forward to jsp, why you need to pre-populate ?? > > "Curtney Jacobs" <[EMAIL PROTECTED]> escribió en el mensaje > news:[EMAIL PROTECTED] > > > Greetings everyone! > > > > > > I would like to preopulate serveral forms with default values retrieve > > from a > > > database upon application startup or after a successful login by the > > user. > > > > I have an approach in mind, however, I am not sure if it is the most > > efficient > > > or best approach. My approach is to use a filter that creates and stores > > in > > > memory default ActionForms. The ActionForm will contain default values > > for select fields (or any other fields) retrieved from a database. The > > ActionForms will be stored within the current user session and then > > controll > > > will be given over to Struts ActionServlet. > > > > > > Another similar approach would be to register a listerner > > (HttpSessionAttributeListener) that would essentially wait for a > > specific attribute to be added into the session (i.e SETUP_FORMS) then it > > would > > query > > > the database for neccessary application setup data. > > > > > > I read the message archive, and a few have suggested calling a "setup > > action" > > > per request that prepopulates the default values in the ActionForm. This > > is a > > > valid approach, but IMHO only for small applications. It just seems that > > there will be to much "traffic" going on between the app and the > > database. Correct me if I am wrong. > > > > If you have gotten this far please share your thoughts on this topic. > > > > Curtney > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Calling A default Action Upon Application Startup
if you need to populate a form, you can do in one action and then forward to jsp, why you need to pre-populate ?? "Curtney Jacobs" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > Greetings everyone! > > > I would like to preopulate serveral forms with default values retrieve from a > database upon application startup or after a successful login by the user. > > I have an approach in mind, however, I am not sure if it is the most efficient > or best approach. My approach is to use a filter that creates and stores in > memory default ActionForms. The ActionForm will contain default values for > select fields (or any other fields) retrieved from a database. The > ActionForms will be stored within the current user session and then controll > will be given over to Struts ActionServlet. > > > Another similar approach would be to register a listerner > (HttpSessionAttributeListener) that would essentially wait for a specific > attribute to be added into the session (i.e SETUP_FORMS) then it would query > the database for neccessary application setup data. > > > I read the message archive, and a few have suggested calling a "setup action" > per request that prepopulates the default values in the ActionForm. This is a > valid approach, but IMHO only for small applications. It just seems that > there will be to much "traffic" going on between the app and the database. > Correct me if I am wrong. > > If you have gotten this far please share your thoughts on this topic. > > Curtney - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!
Greetings! I would like to load default values in my forms upon application startup. Is this possible with STRUTS? Seriously, is this possible with STRUTS? If not, I will have to look some where else for this. Many of my forms have drop down list that enables the user to choose the appropriate values. It would be nice that UPON APPLICATION STARTUP forms that need default values are automatically populated with said values. I am aware that I can call an action that can prepopulate my forms with those values. However, it seems tedious to always call an action to populate a form with default values. Has anyone done this before, if so, I would greatly appreciate some assistance. This is like the upteen post concerning this. I find it hard that no one else needs this or has done this. Regards, Curtney - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Calling A default Action Upon Application Startup
For load your default values at aplication startup you can create a HttpServlet, and load data from database and store in application scope. In struts 1.1 instead of HttpServlet you can create a Struts plugin to do the same. second, when a user need access to one "use case" with default data, create an action that populate your form with data stored in application scope. "Curtney Jacobs" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > Greetings Carlos. Thanks for replying. > > Yes. I can populate a form that way. However, it wouldn't quite give me what I > want. For instance, as the application is initially loaded there should be > default values already in the forms; this should be done prior to any user > action. > > I like your one action approach. Is there a way to call this action as the > application is initially loaded. Again, no user interaction should trigger > this action class. > > Thanks, > > Curtney > > On Monday 04 August 2003 05:09 pm, Aguirre Carlos Federico wrote: > > if you need to populate a form, you can do in one action > > and then forward to jsp, why you need to pre-populate ?? > > > > "Curtney Jacobs" <[EMAIL PROTECTED]> escribió en el mensaje > > news:[EMAIL PROTECTED] > > > > > Greetings everyone! > > > > > > > > > I would like to preopulate serveral forms with default values retrieve > > > > from a > > > > > database upon application startup or after a successful login by the > > > user. > > > > > > I have an approach in mind, however, I am not sure if it is the most > > > > efficient > > > > > or best approach. My approach is to use a filter that creates and stores > > > > in > > > > > memory default ActionForms. The ActionForm will contain default values > > > for select fields (or any other fields) retrieved from a database. The > > > ActionForms will be stored within the current user session and then > > > > controll > > > > > will be given over to Struts ActionServlet. > > > > > > > > > Another similar approach would be to register a listerner > > > (HttpSessionAttributeListener) that would essentially wait for a > > > specific attribute to be added into the session (i.e SETUP_FORMS) then it > > > would > > > > query > > > > > the database for neccessary application setup data. > > > > > > > > > I read the message archive, and a few have suggested calling a "setup > > > > action" > > > > > per request that prepopulates the default values in the ActionForm. This > > > > is a > > > > > valid approach, but IMHO only for small applications. It just seems that > > > there will be to much "traffic" going on between the app and the > > > database. Correct me if I am wrong. > > > > > > If you have gotten this far please share your thoughts on this topic. > > > > > > Curtney > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!
Thanks Nathan, Andrew. I am sorry that my earliler post was not specific and a little bit on the "sassy" side. Yes. My forms are session mapped forms and I will be getting the default values from my database. Andrew, the reason why I decided not use an action to load the default values in the forms is that this would be a query to the database *everytime*. Since, theses default values are static (will never change), I thought it makes more sense to load then upon application startup and have it within the current session. Oops, they should span accross multiple sessions, therefore, as you and Nathan suggested they should be put within the servlet context. Andrew, can you elaborate a littile bit more on the ActionForm reset issue that you mentioned? Thanks. _CJ On Sunday 10 August 2003 11:08 pm, Andrew Hill wrote: > Yeh alright mate. Keep ya hair on and enough with the shouting already! > > Since the forms are only instantiated when a request for that mapping comes > in its gonna be kinda hard to prepopulate values on them cos they dont > exist yet. Indeed unless you are using session mapped forms (such as for a > multipage wizard or such like) the form is only going to exist for the > scope of the request. > > Now Im assuming that you need to read these default values from somewhere > (which must be why you dont just slap em into the form constructors > directly). Since they dont change while the app is running (another > assumption your post didnt bother clarifying) your best bet would be to > read them into some kind of config objects (perhaps even a 'prototype' > instance of the forms in question) and store these in the servlet context. > Implement a struts plugin to do this at startup time. > > You could initialise the values in the form instance from these config > objects in the reset method. Dont forget to do this only on the first reset > (or you will overwite input). > > I reckon you would be best off doing as you were advised and copying the > defaults into the form in an action though rather than overloading the > reset method for this purpose. > > As for the lists of selectable choices in things such as drop downs - that > would best be left as shared beans in servlet scope (like Nathan says in > his reply to your post) - you would only want to copy values into the form > instance for defaults for stuff, as you can have your tags access the > shared beans directly for such tasks as rendering options in selects... > > > -Original Message- > From: Curtney Jacobs [mailto:[EMAIL PROTECTED] > Sent: Monday, 11 August 2003 13:46 > To: Struts Users Mailing List > Subject: UPON APPLICATION STARTUP > > > Greetings! > > I would like to load default values in my forms upon application startup. > Is this possible with STRUTS? Seriously, is this possible with STRUTS? If > not, I > will have to look some where else for this. > > Many of my forms have drop down list that enables the user to choose the > appropriate values. It would be nice that UPON APPLICATION STARTUP forms > that > need default values are automatically populated with said values. > > I am aware that I can call an action that can prepopulate my forms with > those > values. However, it seems tedious to always call an action to populate a > form > with default values. > > Has anyone done this before, if so, I would greatly appreciate some > assistance. > > > This is like the upteen post concerning this. I find it hard that no one > else > needs this or has done this. > > Regards, > > Curtney > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!
select tags or indeed any tag that acts on a collection uses the name property to locate the collection. If in your case you have a collection of values that you load once and share accross every session interacting with your app, load this at startup, say in a startup servlet init and place it into the application context. servletConfig.getServletContext().setAttribute(name, value) Curtney Jacobs wrote: Greetings! I would like to load default values in my forms upon application startup. Is this possible with STRUTS? Seriously, is this possible with STRUTS? If not, I will have to look some where else for this. Many of my forms have drop down list that enables the user to choose the appropriate values. It would be nice that UPON APPLICATION STARTUP forms that need default values are automatically populated with said values. I am aware that I can call an action that can prepopulate my forms with those values. However, it seems tedious to always call an action to populate a form with default values. Has anyone done this before, if so, I would greatly appreciate some assistance. This is like the upteen post concerning this. I find it hard that no one else needs this or has done this. Regards, Curtney - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Calling A default Action Upon Application Startup
Greetings everyone! I would like to preopulate serveral forms with default values retrieve from a database upon application startup or after a successful login by the user. I have an approach in mind, however, I am not sure if it is the most efficient or best approach. My approach is to use a filter that creates and stores in memory default ActionForms. The ActionForm will contain default values for select fields (or any other fields) retrieved from a database. The ActionForms will be stored within the current user session and then controll will be given over to Struts ActionServlet. Another similar approach would be to register a listerner (HttpSessionAttributeListener) that would essentially wait for a specific attribute to be added into the session (i.e SETUP_FORMS) then it would query the database for neccessary application setup data. I read the message archive, and a few have suggested calling a "setup action" per request that prepopulates the default values in the ActionForm. This is a valid approach, but IMHO only for small applications. It just seems that there will be to much "traffic" going on between the app and the database. Correct me if I am wrong. If you have gotten this far please share your thoughts on this topic. Curtney - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Application Startup
It seems to me that the best place to make the connection in ServletContextListener.contextCreated. If the application is unavailable, you can store that in the application context and when requests come in for that resource, you can display in the response that the resource was unavailable. You would also be able to periodically retry establishing the connection if you weren't able to create the connection when the application first started. Having the application send you (or your system administrator) an email or pager message could also be done. - Original Message - From: "Heligon Sandra" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Tuesday, February 11, 2003 01:39 Subject: RE: Application Startup > I would like to know when the ServletContextListener.contextCreated() > function is > called when Tomcat starts ? or is it possible to call this function only on > the first request? > In fact when the first request arrives to Tomcat I have to open an > application session on > our application server to get business data. > This application session is the same for all the clients. > But the creation of this session is transparent for the clients, I cannot > ask him to go to see in the files of Tomcat's log. > That's why if an error occurs at the application session creation, on the > first action > of the client I would like to display an error. Because if the application > session is not > created the client can nothing make. > > If I understood the various remarks well, there are several ways of making: > > - Place code in the ServletContextListener.contextCreated() and use Token > objects > to indicate an error; But we decide to start Tomcat as Windows service but > not our > application server. So I can use this method only if this method is called > on the > first request and not on the Tomcat startup. > > - Override the init() method of the TilesRequestProcessor class; I try this > but > the debug doesn't enter in the overridden method; > > - Use Filter; I am not informed any on this subject where can I find the > best doc about > filters; > > -Original Message- > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 22:56 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > > > On Thu, 6 Feb 2003, Heligon Sandra wrote: > > > Date: Thu, 6 Feb 2003 15:01:44 +0100 > > From: Heligon Sandra <[EMAIL PROTECTED]> > > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > > To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> > > Subject: RE: Application Startup > > > > The problem with the ServletContextListener is that we can not > > display error to the client if an error occur, isn'it ? > > > > If you're doing things at application startup, there *are* no users yet. > > A ServletContextListener.contextCreated() method that detects an error > should write messages to the appropriate log file to describe what > happened (for example, you could call ServletContext.log() for this), plus > throw an exception back to the container. That will cause the container > to not put the application into service, because something was wrong at > startup time. > > In a Servlet 2.2 environment, you'd do exactly the same sort of thing, but > in t he init() method of a servlet marked for instead. > > In either case, the initialization will have been completed by the > container before the application is allowed to start processing requests. > > Craig > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
I would like to know when the ServletContextListener.contextCreated() function is called when Tomcat starts ? or is it possible to call this function only on the first request? In fact when the first request arrives to Tomcat I have to open an application session on our application server to get business data. This application session is the same for all the clients. But the creation of this session is transparent for the clients, I cannot ask him to go to see in the files of Tomcat's log. That's why if an error occurs at the application session creation, on the first action of the client I would like to display an error. Because if the application session is not created the client can nothing make. If I understood the various remarks well, there are several ways of making: - Place code in the ServletContextListener.contextCreated() and use Token objects to indicate an error; But we decide to start Tomcat as Windows service but not our application server. So I can use this method only if this method is called on the first request and not on the Tomcat startup. - Override the init() method of the TilesRequestProcessor class; I try this but the debug doesn't enter in the overridden method; - Use Filter; I am not informed any on this subject where can I find the best doc about filters; -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: 06 February 2003 22:56 To: Struts Users Mailing List Subject: RE: Application Startup On Thu, 6 Feb 2003, Heligon Sandra wrote: > Date: Thu, 6 Feb 2003 15:01:44 +0100 > From: Heligon Sandra <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> > Subject: RE: Application Startup > > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > If you're doing things at application startup, there *are* no users yet. A ServletContextListener.contextCreated() method that detects an error should write messages to the appropriate log file to describe what happened (for example, you could call ServletContext.log() for this), plus throw an exception back to the container. That will cause the container to not put the application into service, because something was wrong at startup time. In a Servlet 2.2 environment, you'd do exactly the same sort of thing, but in t he init() method of a servlet marked for instead. In either case, the initialization will have been completed by the container before the application is allowed to start processing requests. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
On Thu, 6 Feb 2003, Heligon Sandra wrote: > Date: Thu, 6 Feb 2003 15:01:44 +0100 > From: Heligon Sandra <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> > Subject: RE: Application Startup > > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > If you're doing things at application startup, there *are* no users yet. A ServletContextListener.contextCreated() method that detects an error should write messages to the appropriate log file to describe what happened (for example, you could call ServletContext.log() for this), plus throw an exception back to the container. That will cause the container to not put the application into service, because something was wrong at startup time. In a Servlet 2.2 environment, you'd do exactly the same sort of thing, but in t he init() method of a servlet marked for instead. In either case, the initialization will have been completed by the container before the application is allowed to start processing requests. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
Sandra, relax. The token that I am referring to is a general concept; don't take then name "token" so literally. Like I said before, it represents a Java object, any Java object, which encapsulates information which you wish to convey to your application about what happened during initialization. It, the "token", could be as simple an Exception object placed in the ServletContext under a known key name. On each request, your controller looks for that object under the known key name. If it exists, then you can forward to a general error page, else your application knows that it was initialized successfully and it can proceed. If you want a more details about what happened, perhaps your "token" could could wrap the exception along with some additional information, such as a status code. public class ApplicationInitializationInfo { public static final String KEY = ApplicationInitializationInfo.class.getName() + ".key"; public static final int MASSIVE_PROBLEM_CODE = 1; public static final int WARNING_CODE = 2; private Throwable exception; private int statusCode; public Throwable getException() { return this.exception;} public void setException(Throwable t) { this.exception = t;} public int getStatusCode() { return this.statusCode;} public void setStatusCode(int code) {this.statusCode = code;} } In the ServletContextListener: public void contextInitialized(ServletContextEvent sce) { try { // initialize stuff here } catch {Throwable t) { // Uh oh, an error occurred ApplicationInitializationInfo info = new ApplicationInitializationInfo(); info.setException(t); info.setStatusCode(ApplicationInitializationInfo.MASSIVE_ERROR_CODE); // Let the rest of the application know what // the heck is going on so it can act appropriately. sce.getServletContext.setAttribute(ApplicationInitializationInfo.KEY, info); } } HTH, robert > -Original Message- > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 11:12 AM > To: 'Struts Users Mailing List' > Subject: RE: Application Startup > > > Sorry if my question is simple but I am new to Java and Struts, > the Token object about which you speak is different from the Struts > transaction token feature > (that we find in the Action class generateToken(), > isValidToken(),saveToken()). > I have never used Token with Java simple application and Token > with Struts, > so I don't know if there is a difference. Or if "token" defines a general > concept and not a specific object/feature. > > That's why if someone as an example of token-error object with > ServletContextListener > or HttpSessionListener, I am really very very interested thanks a lot in > advance. > > Sandra > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 16:07 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > A token would be any Java object which you create to contain error or > status information and place in ServletContext. > > robert > > > > > -Original Message- > > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 9:49 AM > > To: 'Struts Users Mailing List' > > Subject: RE: Application Startup > > > > > > I don't know that we can use token to do this > > do you have an example, please ? > > > > -Original Message- > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > Sent: 06 February 2003 15:43 > > To: Struts Users Mailing List > > Subject: RE: Application Startup > > > > > > If there is an error, place a token in the ServletContext and have your > > controller check for that token. > > The token can contain error or status information. > > > > robert > > > > > -Original Message- > > > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, February 06, 2003 9:02 AM > > > To: 'Struts Users Mailing List' > > > Subject: RE: Application Startup > > > > > > > > > The problem with the ServletContextListener is that we can not > > > display error to the client if an error occur, isn'it ? > > > > > > > > > -Original Message- > > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > > Sent: 06 February 2003 14:35 > > > To: Struts Users Mailing List > > > Subject: RE: Application Startup > > > > > > > > > Use a Servlet and designate it to load
RE: Application Startup
Sorry if my question is simple but I am new to Java and Struts, the Token object about which you speak is different from the Struts transaction token feature (that we find in the Action class generateToken(), isValidToken(),saveToken()). I have never used Token with Java simple application and Token with Struts, so I don't know if there is a difference. Or if "token" defines a general concept and not a specific object/feature. That's why if someone as an example of token-error object with ServletContextListener or HttpSessionListener, I am really very very interested thanks a lot in advance. Sandra -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED]] Sent: 06 February 2003 16:07 To: Struts Users Mailing List Subject: RE: Application Startup A token would be any Java object which you create to contain error or status information and place in ServletContext. robert > -Original Message- > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:49 AM > To: 'Struts Users Mailing List' > Subject: RE: Application Startup > > > I don't know that we can use token to do this > do you have an example, please ? > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 15:43 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > If there is an error, place a token in the ServletContext and have your > controller check for that token. > The token can contain error or status information. > > robert > > > -Original Message- > > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 9:02 AM > > To: 'Struts Users Mailing List' > > Subject: RE: Application Startup > > > > > > The problem with the ServletContextListener is that we can not > > display error to the client if an error occur, isn'it ? > > > > > > -Original Message- > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > Sent: 06 February 2003 14:35 > > To: Struts Users Mailing List > > Subject: RE: Application Startup > > > > > > Use a Servlet and designate it to load on start up, or if > Servlet2.3 spec, > > look a ServletContextListener. > > > > robert > > > > > -Original Message- > > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, February 06, 2003 8:14 AM > > > To: Struts (E-mail) > > > Subject: Application Startup > > > > > > > > > Hi everyone, > > > > > > I'm using Struts 1.0.2. > > > > > > I need to do some stuff on application startup. I consulted the > > > documentation, and noticed that there's support for such a thing > > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > > > Is there a way I can do some action on application startup in > > > Struts 1.0.2. > > > > > > Please advise, > > > > > > Thanks, > > > > > > Tarek M. Nabil > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
Thanks Robert, that's what I was looking for. -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 06, 2003 5:04 PM To: Struts Users Mailing List Subject: RE: Application Startup Well, there is no guarantee that your application will not _receive_ requests while it is initializing but... If the initialization servlet is configured to load before the Struts ActionServlet, and your application depends on the Struts ActionServlet to handle all application requests, you should be safe. You may want to read the Servlet spec which your container implements to make sure. robert > -Original Message- > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:18 AM > To: Dmitri Ilyin; Struts Users Mailing List > Subject: RE: Application Startup > > > Well, I'm using servlets 2.2, so both ServletContextListener and > Filters are out. > > Now, as for the first idea, even if I designate that the servlet > which I will use to do that initialization starts before the > struts controller. Do I guarantee that all initializations done > by this servlet will be finished before the application receives > any requests? > > This is very important, actually. > > Thanks > > -Original Message- > From: Dmitri Ilyin [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 4:09 PM > To: Struts Users Mailing List > Subject: Re: Application Startup > > > You can use Filter also, just do what you need at the first request > > Dmitri > > - Original Message - > From: "Heligon Sandra" <[EMAIL PROTECTED]> > To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> > Sent: Thursday, February 06, 2003 3:01 PM > Subject: RE: Application Startup > > > > The problem with the ServletContextListener is that we can not > > display error to the client if an error occur, isn'it ? > > > > > > -Original Message- > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > Sent: 06 February 2003 14:35 > > To: Struts Users Mailing List > > Subject: RE: Application Startup > > > > > > Use a Servlet and designate it to load on start up, or if > Servlet2.3 spec, > > look a ServletContextListener. > > > > robert > > > > > -Original Message- > > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, February 06, 2003 8:14 AM > > > To: Struts (E-mail) > > > Subject: Application Startup > > > > > > > > > Hi everyone, > > > > > > I'm using Struts 1.0.2. > > > > > > I need to do some stuff on application startup. I consulted the > > > documentation, and noticed that there's support for such a thing > > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > > > Is there a way I can do some action on application startup in > > > Struts 1.0.2. > > > > > > Please advise, > > > > > > Thanks, > > > > > > Tarek M. Nabil > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
A token would be any Java object which you create to contain error or status information and place in ServletContext. robert > -Original Message- > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:49 AM > To: 'Struts Users Mailing List' > Subject: RE: Application Startup > > > I don't know that we can use token to do this > do you have an example, please ? > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 15:43 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > If there is an error, place a token in the ServletContext and have your > controller check for that token. > The token can contain error or status information. > > robert > > > -Original Message- > > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 9:02 AM > > To: 'Struts Users Mailing List' > > Subject: RE: Application Startup > > > > > > The problem with the ServletContextListener is that we can not > > display error to the client if an error occur, isn'it ? > > > > > > -----Original Message- > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > Sent: 06 February 2003 14:35 > > To: Struts Users Mailing List > > Subject: RE: Application Startup > > > > > > Use a Servlet and designate it to load on start up, or if > Servlet2.3 spec, > > look a ServletContextListener. > > > > robert > > > > > -Original Message- > > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, February 06, 2003 8:14 AM > > > To: Struts (E-mail) > > > Subject: Application Startup > > > > > > > > > Hi everyone, > > > > > > I'm using Struts 1.0.2. > > > > > > I need to do some stuff on application startup. I consulted the > > > documentation, and noticed that there's support for such a thing > > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > > > Is there a way I can do some action on application startup in > > > Struts 1.0.2. > > > > > > Please advise, > > > > > > Thanks, > > > > > > Tarek M. Nabil > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
Well, there is no guarantee that your application will not _receive_ requests while it is initializing but... If the initialization servlet is configured to load before the Struts ActionServlet, and your application depends on the Struts ActionServlet to handle all application requests, you should be safe. You may want to read the Servlet spec which your container implements to make sure. robert > -Original Message- > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:18 AM > To: Dmitri Ilyin; Struts Users Mailing List > Subject: RE: Application Startup > > > Well, I'm using servlets 2.2, so both ServletContextListener and > Filters are out. > > Now, as for the first idea, even if I designate that the servlet > which I will use to do that initialization starts before the > struts controller. Do I guarantee that all initializations done > by this servlet will be finished before the application receives > any requests? > > This is very important, actually. > > Thanks > > -Original Message- > From: Dmitri Ilyin [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 4:09 PM > To: Struts Users Mailing List > Subject: Re: Application Startup > > > You can use Filter also, just do what you need at the first request > > Dmitri > > - Original Message - > From: "Heligon Sandra" <[EMAIL PROTECTED]> > To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> > Sent: Thursday, February 06, 2003 3:01 PM > Subject: RE: Application Startup > > > > The problem with the ServletContextListener is that we can not > > display error to the client if an error occur, isn'it ? > > > > > > -Original Message- > > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > > Sent: 06 February 2003 14:35 > > To: Struts Users Mailing List > > Subject: RE: Application Startup > > > > > > Use a Servlet and designate it to load on start up, or if > Servlet2.3 spec, > > look a ServletContextListener. > > > > robert > > > > > -Original Message- > > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, February 06, 2003 8:14 AM > > > To: Struts (E-mail) > > > Subject: Application Startup > > > > > > > > > Hi everyone, > > > > > > I'm using Struts 1.0.2. > > > > > > I need to do some stuff on application startup. I consulted the > > > documentation, and noticed that there's support for such a thing > > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > > > Is there a way I can do some action on application startup in > > > Struts 1.0.2. > > > > > > Please advise, > > > > > > Thanks, > > > > > > Tarek M. Nabil > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
I don't know that we can use token to do this do you have an example, please ? -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED]] Sent: 06 February 2003 15:43 To: Struts Users Mailing List Subject: RE: Application Startup If there is an error, place a token in the ServletContext and have your controller check for that token. The token can contain error or status information. robert > -Original Message- > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:02 AM > To: 'Struts Users Mailing List' > Subject: RE: Application Startup > > > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 14:35 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, > look a ServletContextListener. > > robert > > > -Original Message- > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 8:14 AM > > To: Struts (E-mail) > > Subject: Application Startup > > > > > > Hi everyone, > > > > I'm using Struts 1.0.2. > > > > I need to do some stuff on application startup. I consulted the > > documentation, and noticed that there's support for such a thing > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > Is there a way I can do some action on application startup in > > Struts 1.0.2. > > > > Please advise, > > > > Thanks, > > > > Tarek M. Nabil > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
If there is an error, place a token in the ServletContext and have your controller check for that token. The token can contain error or status information. robert > -Original Message- > From: Heligon Sandra [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 9:02 AM > To: 'Struts Users Mailing List' > Subject: RE: Application Startup > > > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 14:35 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, > look a ServletContextListener. > > robert > > > -Original Message- > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 8:14 AM > > To: Struts (E-mail) > > Subject: Application Startup > > > > > > Hi everyone, > > > > I'm using Struts 1.0.2. > > > > I need to do some stuff on application startup. I consulted the > > documentation, and noticed that there's support for such a thing > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > Is there a way I can do some action on application startup in > > Struts 1.0.2. > > > > Please advise, > > > > Thanks, > > > > Tarek M. Nabil > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
There is an article about this subject on JGuru http://jguru.com/faq/view.jsp?EID=471960 The article speaks about a Struts example that defines a second servlet before the ActionServlet. But the struts-example.war of the Struts1.1b2 doesn't defined two servlets. Has someone this example ? I use Servlet2.3, so in a first time I would to make initializations in the ServletContextListener but as we can not display error on a JSP page I have to change my code. I don't understand well what kind of initialization can be done in the contextInitialized() method because a lot of initialization (like connection to an application server or database connection) can generate errors. The filter feature doesn't resolve the display of the error, isn't it ? -Original Message- From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] Sent: 06 February 2003 15:18 To: Dmitri Ilyin; Struts Users Mailing List Subject: RE: Application Startup Well, I'm using servlets 2.2, so both ServletContextListener and Filters are out. Now, as for the first idea, even if I designate that the servlet which I will use to do that initialization starts before the struts controller. Do I guarantee that all initializations done by this servlet will be finished before the application receives any requests? This is very important, actually. Thanks -Original Message- From: Dmitri Ilyin [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 06, 2003 4:09 PM To: Struts Users Mailing List Subject: Re: Application Startup You can use Filter also, just do what you need at the first request Dmitri - Original Message - From: "Heligon Sandra" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Thursday, February 06, 2003 3:01 PM Subject: RE: Application Startup > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 14:35 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, > look a ServletContextListener. > > robert > > > -Original Message- > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 8:14 AM > > To: Struts (E-mail) > > Subject: Application Startup > > > > > > Hi everyone, > > > > I'm using Struts 1.0.2. > > > > I need to do some stuff on application startup. I consulted the > > documentation, and noticed that there's support for such a thing > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > Is there a way I can do some action on application startup in > > Struts 1.0.2. > > > > Please advise, > > > > Thanks, > > > > Tarek M. Nabil > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
Well, I'm using servlets 2.2, so both ServletContextListener and Filters are out. Now, as for the first idea, even if I designate that the servlet which I will use to do that initialization starts before the struts controller. Do I guarantee that all initializations done by this servlet will be finished before the application receives any requests? This is very important, actually. Thanks -Original Message- From: Dmitri Ilyin [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 06, 2003 4:09 PM To: Struts Users Mailing List Subject: Re: Application Startup You can use Filter also, just do what you need at the first request Dmitri - Original Message - From: "Heligon Sandra" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Thursday, February 06, 2003 3:01 PM Subject: RE: Application Startup > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 14:35 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, > look a ServletContextListener. > > robert > > > -Original Message- > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 8:14 AM > > To: Struts (E-mail) > > Subject: Application Startup > > > > > > Hi everyone, > > > > I'm using Struts 1.0.2. > > > > I need to do some stuff on application startup. I consulted the > > documentation, and noticed that there's support for such a thing > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > Is there a way I can do some action on application startup in > > Struts 1.0.2. > > > > Please advise, > > > > Thanks, > > > > Tarek M. Nabil > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Application Startup
You can use Filter also, just do what you need at the first request Dmitri - Original Message - From: "Heligon Sandra" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Thursday, February 06, 2003 3:01 PM Subject: RE: Application Startup > The problem with the ServletContextListener is that we can not > display error to the client if an error occur, isn'it ? > > > -Original Message- > From: Robert Taylor [mailto:[EMAIL PROTECTED]] > Sent: 06 February 2003 14:35 > To: Struts Users Mailing List > Subject: RE: Application Startup > > > Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, > look a ServletContextListener. > > robert > > > -Original Message- > > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 06, 2003 8:14 AM > > To: Struts (E-mail) > > Subject: Application Startup > > > > > > Hi everyone, > > > > I'm using Struts 1.0.2. > > > > I need to do some stuff on application startup. I consulted the > > documentation, and noticed that there's support for such a thing > > in Struts 1.1. No mention of it in 1.0.2, though. > > > > Is there a way I can do some action on application startup in > > Struts 1.0.2. > > > > Please advise, > > > > Thanks, > > > > Tarek M. Nabil > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
The problem with the ServletContextListener is that we can not display error to the client if an error occur, isn'it ? -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED]] Sent: 06 February 2003 14:35 To: Struts Users Mailing List Subject: RE: Application Startup Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, look a ServletContextListener. robert > -Original Message- > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 8:14 AM > To: Struts (E-mail) > Subject: Application Startup > > > Hi everyone, > > I'm using Struts 1.0.2. > > I need to do some stuff on application startup. I consulted the > documentation, and noticed that there's support for such a thing > in Struts 1.1. No mention of it in 1.0.2, though. > > Is there a way I can do some action on application startup in > Struts 1.0.2. > > Please advise, > > Thanks, > > Tarek M. Nabil > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Application Startup
Use a Servlet and designate it to load on start up, or if Servlet2.3 spec, look a ServletContextListener. robert > -Original Message- > From: Tarek M. Nabil [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 8:14 AM > To: Struts (E-mail) > Subject: Application Startup > > > Hi everyone, > > I'm using Struts 1.0.2. > > I need to do some stuff on application startup. I consulted the > documentation, and noticed that there's support for such a thing > in Struts 1.1. No mention of it in 1.0.2, though. > > Is there a way I can do some action on application startup in > Struts 1.0.2. > > Please advise, > > Thanks, > > Tarek M. Nabil > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Application Startup
Hi everyone, I'm using Struts 1.0.2. I need to do some stuff on application startup. I consulted the documentation, and noticed that there's support for such a thing in Struts 1.1. No mention of it in 1.0.2, though. Is there a way I can do some action on application startup in Struts 1.0.2. Please advise, Thanks, Tarek M. Nabil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]