aspose file tools*
The moose likes Servlets and the fly likes getting TOMCAT_HOME inside servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting TOMCAT_HOME inside servlet" Watch "getting TOMCAT_HOME inside servlet" New topic
Author

getting TOMCAT_HOME inside servlet

sachin pathak
Greenhorn

Joined: Jun 05, 2002
Posts: 27
How do I get value of a system variable TOMCAT_HOME from inside the servlet. To generalise the question I would say how do you get the value of any environment variable defined by the system
Benjiman Bear
Greenhorn

Joined: Dec 22, 2003
Posts: 1
Sachin Pathak,
You can use the following to obtain an environment variable:
public static String TOMCAT_HOME = System.getProperty("catalina.home");
The above will return the TOMCAT_HOME, but you can substitute any valid environment value for "catalina.home" to retreive the setting, i.e. "java_home".
HTH.
Regards,
Todd Nist
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
If you don't mind, please outline why you would want to do this?
If you decide later to use an other web container, this code will not work. If you need to find the base directory of your web app, use the ServletContext.getResourceAsStream() method, or the class loader's getResourceAsStream method. It's far more portable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting TOMCAT_HOME inside servlet
 
Similar Threads
Tomcat settings
Error:package javax.servlet.jsp.tagext does not exist
Getting an attribute from a JSP
Invalid Flag Error when using javac
setting the environment variables