This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes workdir in production Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "workdir in production" Watch "workdir in production" New topic
Author

workdir in production

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hello
I have a webapp that uses the code below to write scratch files. It works prefectly when executed from local host. It creates and reads files from the servlet/webapp specific directory.

The problem is when I deploy to a production server with a domain and modjk the same code fails to create the file and obviously fails to read it. I want to use the default in production and can fathom why not. I have asked around and been able to advance it to this litmus test. Local code works and creates, domain based deployment, doesn't. Can someone help me understand why and how to fix it? tia

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
CP,

You've posted quite a few times already, so I would have expected you'd be aware of our naming policy. You can read the policy at this link. In particular, the name you display must be a first and last name (not just initials), and must not be obviously fictitious. Please change the Publicly Displayed Name in your user profile so that it meets the guidelines.

This may seem trivial to you, but it's an important part of the culture at JavaRanch, and we do appreciate your compliance with it.


Merrill
Consultant, Sima Solutions
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Culture enforced.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Thanks for making the change. Sorry to be a pain in the butt, but when they make you a moderator, along with the secret handshake, they make you swear to uphold the naming policy.

As for your question: I'd suggest using the getRealPath() method of the ServletContext object. This returns the actual path of the web context wherever it may be on the server. Here's an example:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: workdir in production