The getResource() and getResourceAsStream() methods are used by a servlet to access any resource without worrying about wher the resource actually resides.
For example ServletContext context = getServletContext(); URL url = context.getResorce("somewhere/ug.zip"); InputSteam is = url.openStream(); // etc. T. Kochanowicz -----Original Message----- From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Pramod Nair Sent: Sunday, September 08, 2002 5:30 PM To: Subject: Re: More File IO trouble > could it be possible to create/access a file resource outside the Tomcat > container using getResource() > or you really have to specify the absolute or relative path to where it > resides? According to the Servlets 2.4 specification .. "The ServletContext interface can provide access only to the hierarchy of static content documents that are part of the web application ... This hierarchy of documents may exist in the server's file system, in a WAR file, on a remote server, or at some other location." If you consider the last two phrases (Remote server / Some other location), there appears to be a lot of ambiguity as to what exactly CAN be served through ServletContext.getResource() Tomcat's implementation of ServletContext.getResource() does hint at some kind of JNDI support, but , I guess, as a simple rule, you should place your resources under WEB-INF/ regards Pramod Nair ----- Original Message ----- From: "randie ursal" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, September 09, 2002 4:19 AM Subject: Re: More File IO trouble > i agree with that..coz that's how i create/access my file resources. > > but i have this question because i haven't tried this one yet.... > > could it be possible to create/access a file resource outside the Tomcat > container using getResource() > or you really have to specify the absolute or relative path to where it > resides? > > also, could my Servlet locate the classes/jars being set on the > classpath environment variable without > placing those classes/jar files inside the Tomcat container? > > P.S > > thanks a lot > randie > > > > > > > Pramod Nair wrote: > > > >> As an aside to what Richard mentioned, You should use > >> ServletContext.getResource(String resourcePath) method to access > >> resources > >> within your web application. This would help in making your web > >> application > >> more portable and easier to deploy. > >> > >> regards > >> > >> Pramod Nair > >> > >> ----- Original Message ----- > >> From: "Richard Yee" <[EMAIL PROTECTED]> > >> To: <[EMAIL PROTECTED]> > >> Sent: Saturday, September 07, 2002 11:10 PM > >> Subject: Re: More File IO trouble > >> > >> > >> > >> > >>> Monte, > >>> The path that you show is a relative path and not an absolute path. > >>> put a > >>> leading '/' on the path and try it again. > >>> > >>> -Richard > >>> > >>> > >> > > > > ___________________________________________________________________________ > 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 > ___________________________________________________________________________ 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 ___________________________________________________________________________ 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