wood burning stoves 2.0*
The moose likes Servlets and the fly likes Can I write to a directory outside the j2ee container? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can I write to a directory outside the j2ee container?" Watch "Can I write to a directory outside the j2ee container?" New topic
Author

Can I write to a directory outside the j2ee container?

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
I want my servlet to write to the equivalent of C:\store, however, because I'm using Linux, I want to write to /store. I have tried adding
<virtual-directory virtual-path="/store" real-path="/store/" />
and
<virtual-directory virtual-path="/store" real-path="~//store/" />
and
<virtual-directory virtual-path="/store" real-path="/../../../../../store/" />
to {OC4J_HOME}/j2ee/home/application-deployments/myApp/myApp/orion-web.xml with no success. The webapp still tries to write to
{OC4J_HOME}/j2ee/home/store

Can I write outside the j2ee container?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Yes.
Make sure to use the File class static fields separator and pathSeparator (or the char versions).


SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="http://webtools.servehttp.com" target="_blank" rel="nofollow">http://webtools.servehttp.com</a> down for a while...
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you can indeed, IF the application server allows it (many don't or can have file permissions outside the web application directory disallowed for security reasons).


42
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I write to a directory outside the j2ee container?
 
Similar Threads
Tomcat url redirect problem
adding a Datasource to tomcat jndi
Maybe the experts here would know.
Oc4j Hot deploy for JSP
Need help with Oracle Service Registry configuration