aspose file tools*
The moose likes Servlets and the fly likes file access problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "file access problem" Watch "file access problem" New topic
Author

file access problem

Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
Hi all ,
I have been implementing a small code which will access some files within the same context. Currently I have a servlet and implemented as follow to access the files.



I got the file not found exception when the app is run. "variations.uni" file is placed in the root of the app .My dir structure is as follow



please help me solve this problem.



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

The context path is a concept for URLs, not file paths.

What are you really trying to do? Where do you want the file to be?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
Bear Bibeault wrote:The context path is a concept for URLs, not file paths.



Oh yes,I just want to read/write the file in the root of app .

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Investigate ServletContext.getRealPath()
Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
thanks so much , bear. I havent accessed files with Stream in web environment before and didnt know that method exists. You help me a lot.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

OK, just be aware that writing into your web app is not generally considered a great thing to do. It can make redeployment and updates a pain.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file access problem