-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris,

Chris Richmond wrote:
| Well after I added that entry, I realized I don't have access to any
context
| information/classes since this is just a plain JAX-WS web service and
not a
| web application, so it is not using the JSP/JSR technologies.

You mean that you don't have access to the ServletRequest object? Okay,
then <context-param> isn't going to work for you. <env-entry> is the
answer (or perhaps using a properties file that you load yourself from
somewhere else, which might be more appropriate... you make the call).

| That is my
| understanding anyway.  So my question is, if that is the case, and I
want to
| use those context-params, how *DO* I access it from my code.

I think you're out of luck, unless you want to hack some type of static
object that you can access from anywhere, and whose configuration is
loaded on webapp startup from the <context-param> settings.

| You mention env-entry as well, but I have not used JNDI and am not really
| sure what it even does. I have read about it and seen lots of applied
| examples to other app servers/stacks/toolkits.  But I can't seem to
locate a
| resource that shows how to use JNDI in a tomcat container web service to
| access an env-entry in my WEB-INF/web.xml.
|
| Any pointers to the right resources or samples would be great, but if they
| don't exist, some advice is also greatly appreciated.

The best place to look is usually the source (of the information). I
started with the DTD for the 2.3 web.xml file (2.4 is XML Schema with
virtually no self-documentation, while the older DYD is full of goodies):

"
<!--
The env-entry element contains the declaration of a web application's
environment entry. The declaration consists of an optional
description, the name of the environment entry, and an optional
value.  If a value is not specified, one must be supplied
during deployment.
- -->
<!ELEMENT env-entry (description?, env-entry-name, env-entry-value?,
env-entry-type)>

<!--
The env-entry-name element contains the name of a web applications's
environment entry.  The name is a JNDI name relative to the
java:comp/env context.  The name must be unique within a web application.

Example:

<env-entry-name>minAmount</env-entry-name>

Used in: env-entry
- -->
<!ELEMENT env-entry-name (#PCDATA)>

<!--
The env-entry-type element contains the fully-qualified Java type of
the environment entry value that is expected by the web application's
code.

The following are the legal values of env-entry-type:

~        java.lang.Boolean
~        java.lang.Byte
~        java.lang.Character
~        java.lang.String
~        java.lang.Short
~        java.lang.Integer
~        java.lang.Long
~        java.lang.Float
~        java.lang.Double

Used in: env-entry
- -->
<!ELEMENT env-entry-type (#PCDATA)>

<!--
The env-entry-value element contains the value of a web application's
environment entry. The value must be a String that is valid for the
constructor of the specified type that takes a single String
parameter, or for java.lang.Character, a single character.

Example:

<env-entry-value>100.00</env-entry-value>

Used in: env-entry
- -->
<!ELEMENT env-entry-value (#PCDATA)>
"

As you can see, the <env-entry-name> will be the key in the JNDI
context, but it will be rooted under the java:comp/env sub-tree. This
basically means that you should be able to access that object like this:


<env-entry>
~  <env-entry-name>myObjectKey</env-entry-name>
~  <env-entry-value>This is a string</env-entry-value>
</env-entry>

Context ctx = new InitialContext();
String myString = (String)ctx.lookup("java:comp/env/myObjectKey");

Obviously, if you have data of a different type, you'll want to use the
appropriate object types.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg/EGkACgkQ9CaO5/Lv0PCQpgCglSIHSUMrnYqAjBJXH5FGOGSp
jFsAn0FxTSGQDGyCF7nikZgdzMQ4Js46
=oFSz
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to