A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide
this week in the
create a file in the root directory
Joined: Jul 31, 2008
Apr 20, 2009 13:07:05
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
Please help me out in resolving this issue.
SCJP 80% SCWCD 89%
Author and all-around good cowpoke
Joined: Mar 22, 2000
Apr 20, 2009 14:59:00
Look at the ServletContext getRealPath() method JavaDocs.
I agree. Here's the link:
subject: create a file in the root directory
Simple Servlet Not Working
Save a file on the application root
Directory Creation on FTP Server using Java Program
Creating a JAR file contains TLD-file.
Saving file at server
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015