Getting directory in which app is deployed

2006-02-10 Thread Wojciech Ciesielski
Hi there,

I have one problem... We have to execute external Java process from JAR archive 
included in our web application directory. The problem is, that all system 
dependant functions are relative to tomcat home directory. And - when our 
application is deployed outside tomcat directory via server.xml context 
definition - we cannot find a way to get path to our web directory...

I am not sure if I am expressing myself clear, so example...

I have web app with structure:

someDir/web:
  WEB-INF
  META-INF
  dirWithArchive
externalProgram.jar
  ...

which is deployed OUTSIDE tomcat. I need to execute such code:

Process = new ProcessBuilder(java -jar 
some/path/to/someDir/web/dirWithArchive/externalProgram.jar.split(\\s+).start();

from within struts action or struts plugin. HOW can I find a path without 
specifying it manualy (it's problematic because of different environments we 
deploy our application to).

TIA

Wojciech Ciesielski
Software Mind | Where Quality Meets the Future 
 
mailto:[EMAIL PROTECTED]
tel./fax: +48-12 6145170
http://www.softwaremind.pl
 


Re: Getting directory in which app is deployed

2006-02-10 Thread David Smith
If your webapp is deployed as an exploded app (ie not a .war file), 
ServletContext#getRealPath() should do the trick


--David

Wojciech Ciesielski wrote:

Hi there,

I have one problem... We have to execute external Java process from JAR archive 
included in our web application directory. The problem is, that all system 
dependant functions are relative to tomcat home directory. And - when our 
application is deployed outside tomcat directory via server.xml context 
definition - we cannot find a way to get path to our web directory...

I am not sure if I am expressing myself clear, so example...

I have web app with structure:

someDir/web:
  WEB-INF
  META-INF
  dirWithArchive
externalProgram.jar
  ...

which is deployed OUTSIDE tomcat. I need to execute such code:

Process = new ProcessBuilder(java -jar 
some/path/to/someDir/web/dirWithArchive/externalProgram.jar.split(\\s+).start();

from within struts action or struts plugin. HOW can I find a path without 
specifying it manualy (it's problematic because of different environments we 
deploy our application to).

TIA

Wojciech Ciesielski
Software Mind | Where Quality Meets the Future 
 
mailto:[EMAIL PROTECTED]

tel./fax: +48-12 6145170
http://www.softwaremind.pl
 

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Getting directory in which app is deployed

2006-02-10 Thread Mike Sabroff
have your external process use a script that points to the webdirectory 
or if you use servlets, set an init param in the web.xml or in 
server.xml set an environment variable:

!-- Test entry for demonstration purposes --
   Environment name=simpleValue type=java.lang.Integer value=30/
or set a session variable in a jsp

Wojciech Ciesielski wrote:


Hi there,

I have one problem... We have to execute external Java process from 
JAR archive included in our web application directory. The problem is, 
that all system dependant functions are relative to tomcat home 
directory. And - when our application is deployed outside tomcat 
directory via server.xml context definition - we cannot find a way to 
get path to our web directory...


I am not sure if I am expressing myself clear, so example...

I have web app with structure:

someDir/web:
  WEB-INF
  META-INF
  dirWithArchive
externalProgram.jar
  ...

which is deployed OUTSIDE tomcat. I need to execute such code:

Process = new ProcessBuilder(java -jar 
some/path/to/someDir/web/dirWithArchive/externalProgram.jar.split(\\s+).start();


from within struts action or struts plugin. HOW can I find a path 
without specifying it manualy (it's problematic because of different 
environments we deploy our application to).


TIA

Wojciech Ciesielski
Software Mind | Where Quality Meets the Future

mailto:[EMAIL PROTECTED]
tel./fax: +48-12 6145170
http://www.softwaremind.pl



--
Mike Sabroff
Web Services
Developer
[EMAIL PROTECTED]
920-568-8379


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]