Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Accessing server.xml config settings in a web application

Reply
Thread Tools

Accessing server.xml config settings in a web application

 
 
hitectahir@hotmail.com
Guest
Posts: n/a
 
      03-10-2005
Hi,

I want to use the settings I make in server.xml for Tomcat
configuration in my web application as well. Is there some way I can
use the values stored in server.xml directly through my web application
code instead of having to store them in another properties file?

Regards
Tahir.

 
Reply With Quote
 
 
 
 
Tom Dyess
Guest
Posts: n/a
 
      03-11-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> I want to use the settings I make in server.xml for Tomcat
> configuration in my web application as well. Is there some way I can
> use the values stored in server.xml directly through my web application
> code instead of having to store them in another properties file?
>
> Regards
> Tahir.
>


Is context-param what you are looking for?

<context-param>
<param-name>server</param-name>
<param-value>192.168.1.27</param-value>
</context-param>

--
Tom Dyess
OraclePower.com


 
Reply With Quote
 
 
 
 
littlewild@gmail.com
Guest
Posts: n/a
 
      03-11-2005
To be more specific, you can set the context params in your serverl.xml
and then retrieve them by:
1. Get the ServletConfig object using Servlet.getServletConfig()
2. Get the ServletContext object using
ServletConfig.getServletContext()
3. Get the parameter using ServletContext.getAttribute()

Since each app server will only have one ServletContext object, the
values are shared by all web application. If you want to make the
values specific to just one servlet, you can specify the parameters
inside your application's web.xml as:
<servlet>
......
<init-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</init-param>
</servlet>

You can then retrive the values using ServletConfig.getInitParameter().

Hope it helps.

(E-Mail Removed) wrote:
> Hi,
>
> I want to use the settings I make in server.xml for Tomcat
> configuration in my web application as well. Is there some way I can
> use the values stored in server.xml directly through my web

application
> code instead of having to store them in another properties file?
>
> Regards
> Tahir.


 
Reply With Quote
 
Malte
Guest
Posts: n/a
 
      03-11-2005
Tom Dyess wrote:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>
>>Hi,
>>
>>I want to use the settings I make in server.xml for Tomcat
>>configuration in my web application as well. Is there some way I can
>>use the values stored in server.xml directly through my web application
>>code instead of having to store them in another properties file?
>>
>>Regards
>>Tahir.
>>

>
>
> Is context-param what you are looking for?
>
> <context-param>
> <param-name>server</param-name>
> <param-value>192.168.1.27</param-value>
> </context-param>
>


I am not sure, but wouldn't program parms be better written into web.xml?
 
Reply With Quote
 
hitectahir@hotmail.com
Guest
Posts: n/a
 
      03-11-2005
Thanks for the response, but I actually want to retrieve the properties
that have been set for the connectors. More specifically, my web
application supports both http and https communication. However, over
http, it uses the same keystore being used by the SSL Connector to
authenticate with the client. Currently, I have to put the path to the
keystore file in both server.xml and a separate properties file. Is
there some way I can get this path directly from server.xml instead of
having to put it in another file as well?

Thanks
Tahir.

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> To be more specific, you can set the context params in your

serverl.xml
> and then retrieve them by:
> 1. Get the ServletConfig object using Servlet.getServletConfig()
> 2. Get the ServletContext object using
> ServletConfig.getServletContext()
> 3. Get the parameter using ServletContext.getAttribute()
>
> Since each app server will only have one ServletContext object, the
> values are shared by all web application. If you want to make the
> values specific to just one servlet, you can specify the parameters
> inside your application's web.xml as:
> <servlet>
> ......
> <init-param>
> <param-name>foo</param-name>
> <param-value>bar</param-value>
> </init-param>
> </servlet>
>
> You can then retrive the values using

ServletConfig.getInitParameter().
>
> Hope it helps.
>
> (E-Mail Removed) wrote:
> > Hi,
> >
> > I want to use the settings I make in server.xml for Tomcat
> > configuration in my web application as well. Is there some way I

can
> > use the values stored in server.xml directly through my web

> application
> > code instead of having to store them in another properties file?
> >
> > Regards
> > Tahir.


 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a
 
      03-13-2005
(E-Mail Removed) said:
>Thanks for the response, but I actually want to retrieve the properties
>that have been set for the connectors. More specifically, my web
>application supports both http and https communication. However, over
>http, it uses the same keystore being used by the SSL Connector to
>authenticate with the client. Currently, I have to put the path to the
>keystore file in both server.xml and a separate properties file. Is
>there some way I can get this path directly from server.xml instead of
>having to put it in another file as well?


I don't think you can (easily) get to that information:

As I see it, providing webapp access to the _server_ keystore could
compromise the security/integrity of the server (of course a non-issue
if the server is just running a single application, but it is a design
issue as the server is designed to simultaneously run several
independent webapps).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Settings.settings file with settings for multiple regions donet programmer ASP .Net 3 11-20-2009 03:05 PM
Accessing system.web config settings in medium trust daveh551 ASP .Net 0 11-29-2008 12:35 AM
Class Library reading web.config Settings OR app.config settings leeanne ASP .Net 0 09-24-2008 05:36 PM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
Web.Config Get Config settings at runtime. =?Utf-8?B?QXVndXN0aW4gUHJhc2FubmEuIEo=?= ASP .Net 3 02-06-2004 01:17 PM



Advertisments