• Post Reply Bookmark Topic Watch Topic
  • New Topic

File I/0  RSS feed

 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was wondering, since whenever I try to use just a filename in a servlet, it doesn't create it(rather I must specify an entire path (C:\...\...\filename.txt)), is there any way to get the document base, like in JApplets, except with a string returned?
Thanks,
Parth
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use just a file name, the "current" directory is assumed - in a servlet environment you have no control over the "current" directory.
You can get a complete path to use several ways:
1. As an init parameter in web.xml to the servlet
2. See the getRealPath method in the ServletContext
3. Hard code in your servlet
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!