You can use getRealPath to get a physical mapping for a virtual path

ServletContext sc = ServletConfig.getServletContext() ;

sc.getRealPath();

You can use an existing virtual path or create a new virtual directory for your
user files.

If you do not want to use a virtual directory , you can parse the drive letter
from the getRealPath and append your folder name and users.txt to it.



Santosh







kumar seema <[EMAIL PROTECTED]> on 05/08/2001 11:48:09 AM

Please respond to A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Santosh Daryani/IT/Aon Consulting)

Subject:  Problem with the absolute path of a file



Hi all,

I use JavaWebServer2.0 to run my JSP pages.
I have a text file from which my JSP page reads from.
I use the RandomAccessFile object in java to read and
write into the file. The file is currently placed in
the "public_html" directory of the JavaWebServer.

My problem is that while opening the file I have to
specify the entire path as in :
file = new
RandomAccessFile("c:\\JavaWebServer2.0\\public_html\\users.txt","r");


Is there any way in which I can get rid of the entire
path and just specify "users.txt" as the path so that
the page will pick it up from there ? Is there any
predefined directory to keep the txt files ?
Please help as I require this to make my code
portable.

Thanks,
Seema

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to