Costin Manolache wrote:
> I know everyone will tell me I'm wrong again, but it seems getResource()
> might have a more "static" meaning.
>
> Most of the time people use ClassLoader.getResource() to get various
> files in classpath.
>
I don't think you're wrong on this one, Costin :-)
Your view of getResource() to retrieve "static" resources, versus
RequestDispatcher to connect to "active" resources, is exactly the way I think
about them in my head.
Why use getResource versus just opening the file itself? Because you don't need
to know anything about absolute pathnames. In the case of
ClassLoader.getResource(), it finds the resource relative to the classpath -- in
the case of ServletContext.getResource(), it finds the resource relative to the
configured resource base for that context (with the additional feature that you
can retrieve any URL-addressable resource, not just local disk files).
No more having to pass initialization parameters to servlets saying "my
properties files and other resources are in directory xyz".
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html