File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Filesystem access from servlet or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filesystem access from servlet or not" Watch "Filesystem access from servlet or not" New topic

Filesystem access from servlet or not

Michael Laufer

Joined: May 30, 2002
Posts: 29

I am just thinking about file system access from my servlet. Is it better to load my deplyoed properties files via the classloader or via a File object? Are there any reasons, i.e. security, that are related to this issue? What is the specification saying about this issue?

Any help is really appreciated.

Thanks in advance & kind regards, Michel
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Read this: Smartly load your properties

Usually in servlets, you can use ServletContext.getResource(), getResourceAsStream() to load resources in that particular context.

SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="" target="_blank" rel="nofollow"></a>
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Definitely load it as a Stream rather than accessng it as a File, since you can't get a File reference if you pack it in a JAR
I agree. Here's the link:
subject: Filesystem access from servlet or not
It's not a secret anymore!