Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

servlet document root 1

Status
Not open for further replies.

MrTom

Programmer
Mar 13, 2001
383
GB
where can i get the document root for a servlet? i just want to load 'test.txt' without having to specify a full path but no matter where i put test.txt it never finds it.
 
correct me if i am wrong, are u referring to

path = getServletConfig.getServletContext.getRealPath("/");
File f = new File(path+"file");

retrieve the file if file is at eg or

InputStream in = this.getClass().getResourceAsStream("filename");

retrieve the file if file is at the same directory as the servlet
 
ah yes!

(can you tell i don't know wot i'm doing? ;)

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top