See below what I did. This works for me and no one offered any reasons not to do it this way so marking it as a solution.
Thanks, Chris -----Original Message----- From: Chris Richmond [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2008 10:08 AM To: 'Tomcat Users List' Subject: RE: accessing web.xml Ok, Here is what I did that works. In my web.xml I have this entry right inside my web-app parent element: <web-app version="2.5" blah blah> <env-entry> <env-entry-name>myvalue</env-entry-name> <env-entry-value>chris was here</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> Then from any class within my JAX-WS web service package structures I include the following: import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; and access it like so: Context ctx = (Context) new InitialContext().lookup("java:comp/env"); String myvalue = (String)env.lookup("myvalue"); And this successfully retrieves the value "chris was here" into my variable for usage (think connection string). So, this works, seems clean, but is there any reason I should not be doing it this way? If no one has any objections, I will set this topic to [RESOLVED] at COB(Hawaii time) so others can see how I resolved it. Thanks, Chris -----Original Message----- From: Terence M. Bandoian [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2008 8:41 AM To: Tomcat Users List Subject: Re: accessing web.xml Hi- Another reasonable approach would be to set system properties either in the startup script or in the Windows registry if you're running as a service. -Terence M. Bandoian >>> Subject: >>> Re: accessing web.xml >>> From: >>> Christopher Schultz <[EMAIL PROTECTED]> >>> Date: >>> Thu, 29 May 2008 11:14:44 -0400 >>> To: >>> Tomcat Users List <users@tomcat.apache.org> >>> >>> To: >>> Tomcat Users List <users@tomcat.apache.org> >>> >>> Message-ID: >>> <[EMAIL PROTECTED]> >>> MIME-Version: >>> 1.0 >>> In-Reply-To: >>> <[EMAIL PROTECTED]> >>> Content-Type: >>> text/plain; charset=UTF-8; format=flowed >>> Content-Transfer-Encoding: >>> 7bit >>> >>> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Chris, >>> >>> Chris Richmond wrote: >>> | I have created a web service using JAX-WS and deployed my .war and it runs >>> | fine, but now I want to convert some hard-coded config values to read >>> values >>> | from the WEB-INF/web.xml file that was created/deployed. >>> >>> Sounds good. >>> >>> | I have addes something like the following to my web.xml: >>> | >>> | <context-param> >>> | <description>test context param</description> >>> | <param-name>testParam</param-name> >>> | <param-value>my value</param-value> >>> | </context-param> >>> >>> Rest assured... this is a reasonable choice for configuring your webapp. >>> There is a thread on this list right now where some folks are arguing >>> over how best to do this (see thread "Best practice? configuration of a >>> web application"). <context-params> in web.xml is as good as any method IMO. >>> >>> | And I want to access it from any of my classes within my web service. >>> >>> Okay. What have you tried? What container objects do you have access to? >>> Can you get to the request? >>> >>> | Perhaps I shouldn't be using <context-param> at all, but some other >>> type of >>> | entry in web.xml? In either case, I can't seem to figure out how to >>> locate >>> | and use an entry like that from within any class in my JAX-WS web >>> service. >>> >>> You could use <env-entry> instead, and then those settings would be >>> available via JNDI (which you can get to from anywhere) instead of >>> through the ServletContext (which you might not have available). >>> >>> - -chris --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]