This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes portability issues with file i/o Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "portability issues with file i/o" Watch "portability issues with file i/o" New topic
Author

portability issues with file i/o

Micah Wedemeyer
Ranch Hand

Joined: Jun 11, 2001
Posts: 68
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

Joined: Jun 11, 2001
Posts: 68
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

Joined: Jun 25, 2001
Posts: 16020
    
  20

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...


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: portability issues with file i/o