> > I'm wanting to place my servlet in multiple locations under the
> > webapps folder so that I can be servicing more than 1 source of a
[quoted text clipped - 16 lines]
>
> robert
That would necessitate having the config file be re-read each time the
request was made.
Thinking on it more, I'm thinking now wrapping the servlet into a
management servlet whose sole purpose would be to evaluate the pathing
and invoke the proper (now class, previous servlet) instance.
I'm reasonably certain this situation has popped up before; just
wondering what the proper solution is.
Thanks,
- Craig Taylor
Kai Schwebke - 15 Mar 2007 19:14 GMT
>> IMHO a superior approach would be to map the servlet to multiple paths
>> in web.xml and make the servlet pick a config file based on the path.
> That would necessitate having the config file be re-read each time the
> request was made.
A servlet is created only once and persists between requests, so the
config file is read on the first request only.
> Thinking on it more, I'm thinking now wrapping the servlet into a
> management servlet whose sole purpose would be to evaluate the pathing
> and invoke the proper (now class, previous servlet) instance.
This solution is well known as "Front Controller Pattern":
http://java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html
Kai
Lew - 16 Mar 2007 04:08 GMT
Craig Taylor wrote:
>> Thinking on it more, I'm thinking now wrapping the servlet into a
>> management servlet whose sole purpose would be to evaluate the pathing
>> and invoke the proper (now class, previous servlet) instance.
> This solution is well known as "Front Controller Pattern":
>
> http://java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html
For an implementation:
<http://struts.apache.org/>
-- Lew
Robert Klemme - 16 Mar 2007 14:15 GMT
>>> I'm wanting to place my servlet in multiple locations under the
>>> webapps folder so that I can be servicing more than 1 source of a
[quoted text clipped - 16 lines]
> That would necessitate having the config file be re-read each time the
> request was made.
No, that completely depends on your code. You could load config files
on demand and store extracted data in the session / application context
or even internally - whatever is most appropriate for your app. You can
even check whether the config file has changed on disk and reread etc.
> Thinking on it more, I'm thinking now wrapping the servlet into a
> management servlet whose sole purpose would be to evaluate the pathing
> and invoke the proper (now class, previous servlet) instance.
"class"?
> I'm reasonably certain this situation has popped up before; just
> wondering what the proper solution is.
I am still unsure about what exactly you mean by "this situation".
Maybe you post a bit more explanation on what the application is
supposed to do and what information is stored in those config files.
Kind regards
robert