• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Find Tomcat location

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a method or something I can use in my Java helper class to find the Tomcat Home location on the server?
For example here is what the path might look like on the Server: C:\TomcatHome\webapps\myfile.jsp

In other language like Cold Fusion I can put in something like ExpandPath function and it will grab the Server Cold Fusion JRUN location: #ExpandPath#webapps\myfile.jsp

Does Java have anything like that?
[ May 05, 2008: Message edited by: Mike Jenkins ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you really looking for the location of the Tomcat installation, or the location of the web app (which may or may not be co-located)? If the former, I hear many whistles and see many red flags. What would you do with this information?
 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Are you really looking for the location of the Tomcat installation, or the location of the web app (which may or may not be co-located)? If the former, I hear many whistles and see many red flags. What would you do with this information?



Thanks,

I need the location of the Tomcat installation only.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried this on a Linux box and a Windows box (with Tomcat installed and running as a service) and it worked.
In both cases it was Tomcat 5.5

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing to keep in mind.
Tomcat can be configured to run multiple instances from the same code base.
When doing this, the admin will typically set up a TOMCAT_HOME and, for each instance, a TOMCAT_BASE environment variable (it might be the other way around but the point is the same) so the value returned might not always be what you're looking for.

With disk space being so cheap these days, it's probably somewhat rare to see a configuration like this.


Another thought is that a good administrator will be sure to run Tomcat under a security manager with a policy that doesn't allow calls to System and, in particular, System.getProperties

What you want to do might not be possible in all environments.

-Ben
[ May 05, 2008: Message edited by: Ben Souther ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
What you want to do might not be possible in all environments.

As I said: red flags. What is it you are actually trying to accomplish?
 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again for all info.

I want to use this for File I/O work.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you be doing file/IO work in within the Tomcat directory structure?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic