Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

portability issues with file i/o

 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any sort of specifics as to where a servlet's "home" directory is? When my servlet writes a file, it seems almost arbitrary where it goes. On Tomcat it goes into the /bin directory while on JRun 2.3 it goes into the enclosing web server main directory. This is causing problems for me on JRun due to read/write security restrictions.
I suppose it would be possible to give an absolute path, but this would destroy portability across even a single machine, let alone multiple Servlet Engines. Does anyone have any suggestions?
Micah
 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. After some concerted searching on the rest of the board I found the getServletContext().getRealPath() stuff.
Thanks to anyone who was going to help
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. I think you may have solved quite a few people's problems here. However, this isn't literally the "home" of the servlet - it's the absolute pathname for a given context (virtual path), so it's not for everyone. And they did note it breaks down if the item in question's inside a "WAR".
Still, it's good to know...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic