• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create a file in the root directory

 
Praveen Sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
based on some user action I need to create a file on the server inside the project's root directory. The url of my application is :
http://localhost:8080/Desk/Desk.html.

The name of the file is DeskItems.xml.

I tried to get the application Context path and appended that to the file name by using :
getServletContext.getPath("/") + "/DeskItems.xml";

But this approach is not working and I get an exception saying FileNotFound. I am using Tomcat server.

Please help me out in resolving this issue.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the ServletContext getRealPath() method JavaDocs.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic