Howdy, >good point, although if you need to write to the file, getResourceAsStream >doesn't work. Is there something else along the same lines that will?
How's about: URL destinationURL = ...getResource(...); URLConnection destinationConnection = URL.openConnection(); destinationConnection.setDoOutput(); OutputStream outputStream = destinationConnection.getOutputStream(); ... You are not guaranteed this will always work across containers. I don't think the spec says the container *has* to give you write permission to URLs obtained this way. Yoav Shapira Millennium ChemInformatics > > >> -----Original Message----- >> From: Larry Meadors [mailto:[EMAIL PROTECTED]] >> Sent: Wednesday, August 14, 2002 10:11 AM >> To: [EMAIL PROTECTED] >> Subject: RE: Quick Question >> >> >> IMO, it seems like a bad idea to me to tie your bean >> code to a servlet context unless you REALLY need to. >> >> To me, a better way would be to put the file in a >> directory under classes, and use the classloader of >> the current thread to get to the file. >> >> This way, you do not need servlet.jar to use your bean >> if you every decide to use it outside of a servlet. >> >> This is a very simple process. Here is an example: >> >> private InputStream getFile(String name){ >> return Thread. >> currentThread(). >> getContextClassLoader(). >> getResourceAsStream(name); >> } >> >> To read a properties file classes/myprops.properties >> for instance, you just do this: >> >> Properties p = new Properties(); >> p.load(getFile("myprops.properties")); >> >> Larry >> >> >>> [EMAIL PROTECTED] 08/14/02 08:42 AM >>> >> It will work in a bean if you pass a reference >> to the servlet context to it... >> >> -- >> To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> > > >-- >To unsubscribe, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]>
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: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
