You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thom Park <tp...@inprise.com> on 2000/11/08 03:35:35 UTC

accessing env-entries from servlet

Hi,

I've set up a webapp to define an env-entry and all looks well,
Tomcat has identified the correct env-entry type/name/value and
stuck
the data in the Hashtables in the Context.

Can someone suggest how to access this data? I've tried the
'standard'
way (defining a javax.naming.InitialContext) and tried to look
it up as a java:comp/env naming construct but I'm finding that
as I haven't set up service provider this approach fails with a
NoInitialContextException.

I understand why this is the case but I'm wondering how one is
meant to get at these env-entry things in the first place. Does
Tomcat have a service provider that can let me have access to
the env-entry hashtable objects squirreled away in the Context
object (note Tomcat context not naming context)?

If not, how are these things meant to be used, if not in the
standard way.

Right now, it looks to me that I'm going to have to build my own
support for these things and expose the object/name lookup via
my own service provider = that seems an awful lot of work to
access something that seems to be already there ;-)

Can anyone advise me that might have used the env-entry
constructs before with Tomcat 3.2?

thanks,

Thom



Re: accessing env-entries from servlet

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Thom Park wrote:

> Hi,
>
> I've set up a webapp to define an env-entry and all looks well,
> Tomcat has identified the correct env-entry type/name/value and
> stuck
> the data in the Hashtables in the Context.
>
> Can someone suggest how to access this data? I've tried the
> 'standard'
> way (defining a javax.naming.InitialContext) and tried to look
> it up as a java:comp/env naming construct but I'm finding that
> as I haven't set up service provider this approach fails with a
> NoInitialContextException.
>
> I understand why this is the case but I'm wondering how one is
> meant to get at these env-entry things in the first place. Does
> Tomcat have a service provider that can let me have access to
> the env-entry hashtable objects squirreled away in the Context
> object (note Tomcat context not naming context)?
>

Tomcat 3.x, as well as versions up to and including Tomcat 4.0 milestone
4, do not have support for a naming context by themselves (although when
Tomcat is embedded in a J2EE server, this support is provided by the
server).  As such, you cannot access <env-entry>, <resource-ref>, or
<ejb-ref> type information.  The alternative is to use context
initialization parameters (<context-parm>) for global config
information.

Support for naming contexts is being actively developed for Tomcat 4.0,
and should be available in milestone 5.

>
> If not, how are these things meant to be used, if not in the
> standard way.
>
> Right now, it looks to me that I'm going to have to build my own
> support for these things and expose the object/name lookup via
> my own service provider = that seems an awful lot of work to
> access something that seems to be already there ;-)
>
> Can anyone advise me that might have used the env-entry
> constructs before with Tomcat 3.2?
>

If you're using 3.2, you will either need to roll your own support, or
use context parameters instead.

>
> thanks,
>
> Thom

Craig McClanahan