Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filesystem access from servlet or not

 
Michael Laufer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this: Smartly load your properties

Usually in servlets, you can use ServletContext.getResource(), getResourceAsStream() to load resources in that particular context.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic