tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Evans <>
Subject RE: Accessing resource in WEB-INF outside servlet
Date Mon, 08 Nov 2004 13:52:24 GMT
Is using JNDI to access a file like this a reasonable approach? I just
started using JNDI to name my database connections via a connection
pool. And when i saw the simplicity of accessing the JNDI context within
my java classes, i got to thinking that i should use it to access many
of my applications configuration variables, such as the location of
various directories for templates and uploads. it seems much cleaner
than passing the request around just to get at the application scope.

Could the original poster stick either the file location in the JNDI
context, so he could easily reference it later, or if the file wasn't
too large, use a custom resource factory to wrap its contents in a bean
and then use the JNDI context to access the file contents.

I haven't tried any of this myself, but was planning to in the next week
or two, when i got some time. Can anyone point out pros and cons of this

the link to the tomcat/JNDI documentation:


On Mon, 2004-11-08 at 
08:03, Shapira, Yoav wrote:
> Hi,
> Then you have a screwed up design.  There's no portable way to get the ServletContext
to fit your needs, and there's no way to make Class#getResource read /WEB-INF unless you write
a custom ClassLoader.  Change your approach.
> Yoav Shapira
> >-----Original Message-----
> >From: Morkeleb []
> >Sent: Sunday, November 07, 2004 10:51 AM
> >To:
> >Subject: Accessing resource in WEB-INF outside servlet
> >
> >Hi.
> >
> >I have a file in WEB-INF which I want to access.
> >However, this is done in a static class which is not a servlet,
> >so I do not have the servlet context.
> >
> >Is there a way to access the servlet context non the less?
> >Is there a way to make getResource find the file anyway?
> >
> >I know a resource is found when it's in /WEB-INF/classes,
> >but it is only in /WEB-INF/ and it is not an option to move
> >it to the classes directory.
> >
> >Can you help me?
> >Thanx in Advance,
> >Lukas Österreicher
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> >For additional commands, e-mail:
> This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged.  This e-mail
is intended only for the individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the sender.  Thank you.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message