Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

workdir in production

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Culture enforced.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic