You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Serge Knystautas <se...@lokitech.com> on 2000/05/10 00:19:37 UTC
Application scope settings
I've written a little servlet that looks at the servlet context's
/WEB-INF/attributes.xml file, parses this as an XML document, and sets a
collection of name/value pairs as attributes on the servlet context.
The attributes.xml looks something like this:
------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<-- no DTD written yet -->
<attributes>
<attribute>
<name>dbconnfile</name>
<value>file:/usr/local/conndefinition.txt</value>
</attribute>
</attributes>
------------------------------------------
We found this a convenient for configuring application specific settings
that our servlets and JSPs can use. There's probably a better way to do
this, but this works for me (better approaches appreciated). Can anyone
tell me a better place put this kind of code? I'd rather this not be a
servlet and just part of the actual servlet engine as it will be easier
to distribute, and I think this would be a useful feature for others.
If anyone can point me to the right package or classes to look through,
I'd be happy to send in a patch to incorporate this into Tomcat.
Serge Knystautas
Loki Technologies
http://www.lokitech.com/
Re: Application scope settings
Posted by Hans Bergsten <ha...@gefionsoftware.com>.
Serge Knystautas wrote:
>
> I've written a little servlet that looks at the servlet context's
> /WEB-INF/attributes.xml file, parses this as an XML document, and sets a
> collection of name/value pairs as attributes on the servlet context.
How is this different from setting context init parameters through
web.xml?
<web-app>
<context-param>
<param-name>dbconnfile</param-name>
<param-value>file:/usr/local/conndefinition.txt</param-value>
</context-param>
</web-app>
These parameters are accessible to servlets and JSPs in the application
though the ServletContext.getInitParameter() method.
Hans
> The attributes.xml looks something like this:
>
> ------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <-- no DTD written yet -->
>
> <attributes>
> <attribute>
> <name>dbconnfile</name>
> <value>file:/usr/local/conndefinition.txt</value>
> </attribute>
> </attributes>
> ------------------------------------------
>
> We found this a convenient for configuring application specific settings
> that our servlets and JSPs can use. There's probably a better way to do
> this, but this works for me (better approaches appreciated). Can anyone
> tell me a better place put this kind of code? I'd rather this not be a
> servlet and just part of the actual servlet engine as it will be easier
> to distribute, and I think this would be a useful feature for others.
> If anyone can point me to the right package or classes to look through,
> I'd be happy to send in a patch to incorporate this into Tomcat.
>
> Serge Knystautas
> Loki Technologies
> http://www.lokitech.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
--
Hans Bergsten hans@gefionsoftware.com
Gefion Software http://www.gefionsoftware.com