Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

create a file in the root directory

Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :

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.
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the ServletContext getRealPath() method JavaDocs.

    Bookmark Topic Watch Topic
  • New Topic