Khang, I think you are over complicated the problem you are trying to solve. Here is my 2 cents.
1) Initiating application objects, you write at startup servlet and in it init method load all the objects you want in your application scope. you only do this once for the life time of your application. 2) Initiation session objects. Since this is per user you can't do it in the startup servlet. there is a lot of way to this. One of them is to create an Abstract Action that extends from the Action class that have an abstract command method that all you action derive from it. And all that you need to implement in the perform method is call your precondition method that do all the session stuff you wants. *** usually getting and creating object on your session or application scope you write a helper class to do it ... > -----Original Message----- > From: nguyen tuan khang [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, May 16, 2002 7:18 PM > To: Struts Developers List > Subject: application and session initiation > > Hi all, > > Please help me the best solution for initiating application and session > objects in common projects. > > Assume > > 1. I have a jsp web page that use both session and application object of > session user. Meaning that the session and application objects must be > initiated somewhere before the user comes to this jsp page (!!!) > > test.jsp > ... > <jsp:usebean name="SessionObject" scope="session" class="..."/> > <jsp:usebean name="ApplicationObject" scope="application" class="..."/> > //user SessionObject and ApplicationObject here > ... > > 2. an URL test is mapped to test.jsp > meaning that when user browses localhost://project/test, the test.jsp is > invoked > > 3. the test URL does not need an Action, because there is no tasks for it. > > my current solutions: > > 1. I have to create one Action for test URL, the Action is responsible to > lookup these objects in Session and Application, if not found the action > initiats SessionObject and Application then put them in Session and > Context. > This is bad because: > It is not worth creating Action like this (waste of time), and of > course > in project there is a lot of url like this so the same number of Actions > are > created in wasting because we are not sure which direct URL (like above) > user comes first (in order to put the initiation correctly) so we have to > put the initiation as above in all Actions (sure that the next just need > to > lookup in Session and Context is enough), it means that the initiation is > put in all actions but the really initiation is occured in only one > Action, > then the rest could lookup in Session and Context. > > 2. I use HttpSessionListener (Servlet 2.3), but I do not know why I > invalidate the session, the Listener's sessionCreate method is not > invoked, > it need restart web server. > > 3. I tried to override the init method in ActionServlet, but it is not > good > for both session and application objects initiation.The same as the second > solution, sometimes the init method of ActionServlet is not invoked if I > call above URL (direct URL) it need restart web server > > Please help me show best solution > thank in advance > regards > Khang > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>