I am confused.
I merely want to reference a file from within a servlet(s). I want to keep my apps transportable so I have a var like this: String myVar = "db/config.dat"; Where is it looking for this file. If the servlet is here: $TCAT_HOME/ROOT/WEB-INF/classes/MyServlet, where will it look for the db directory? Thanks, CC -----Original Message----- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 04, 2002 11:40 PM To: Tomcat Users List Subject: Re: Relative Servlet Path Well, if you are talking about context.getRealPath("/"), that points to the root of your webapp. If you were to append your "db/file.dat" to that, you would be looking for it in: MyContext/ db/file.dat WEB-INF/web.xml I assume you want your db file hidden from view so I'd do: getRealPath("/WEB-INF/db") Note that this is no relative to the current servlet. It is relative to the current context. Also note that getRealPath("/") will return "null" if your app is deployed directly from a .war file and not and expanded directory, so be careful about this usage. Jake At 02:44 PM 9/4/2002 -0700, you wrote: > >If I have a servlet, say ROOT/WEB-INF/classes/MyServlet, what would be >the relative path for this servlet. ie: If I have a variable as such: > >String myconfig = "db/file.dat"; > >What is this path relatvie to, would it be the same directory as the >servlet, thus I would create ROOT/WEB-INF/classes/db ? > >Sorry if this is newbie, I have only been using tomcat for 2 weeks. > >Thanks, >Chuck > >Chuck Carson >Sr. Systems Administrator >Syrrx, Inc. >10410 Science Center Drive >San Diego, CA 92121 >E: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >W: 858.731.3540 >M: 858.442.0827 > > >---------- >This message contains confidential information and is intended only for >the individual named. If you are not the named addressee you should not >disseminate, distribute or copy this e-mail. Please notify the sender >immediately by e-mail if you have received this e-mail by mistake and >delete this e-mail from your system. E-mail transmission cannot be >guaranteed to be secure or error-free as information could be >intercepted, corrupted, lost, destroyed, arrive late or incomplete, or >contain viruses. The sender therefore does not accept liability for any >errors or omissions in the contents of this message, which arise as a >result of e-mail transmission. If verification is required please >request a hard-copy version. ---------- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
