Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

Accessing server.xml config settings in a web application

Thread view: 
hitectahir@hotmail.com - 10 Mar 2005 22:58 GMT
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.
Tom Dyess - 11 Mar 2005 02:03 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> 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>

Signature

Tom Dyess
OraclePower.com

Malte - 11 Mar 2005 04:41 GMT
>>Hi,
>>
[quoted text clipped - 12 lines]
>    <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?
littlewild@gmail.com - 11 Mar 2005 04:20 GMT
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.

hitecta...@hotmail.com wrote:
> Hi,
>
[quoted text clipped - 5 lines]
> Regards
> Tahir.
hitectahir@hotmail.com - 11 Mar 2005 23:58 GMT
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.

> To be more specific, you can set the context params in your serverl.xml
> and then retrieve them by:
[quoted text clipped - 30 lines]
> > Regards
> > Tahir.
Juha Laiho - 13 Mar 2005 13:05 GMT
hitectahir@hotmail.com said:
>Thanks for the response, but I actually want to retrieve the properties
>that have been set for the connectors. More specifically, my web
[quoted text clipped - 4 lines]
>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).
Signature

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)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.