alskdj80
asked on
java variable for tomcat document root?
is there a java variable or method that can return tomcat's document root?
TOMCAT_HOME ??
that's an environment variable
ASKER
hmm, how would i get that variable in a servlet?
Try this. But, I hope someone has an easier way.
String path = getServletContext().getRea lPath("/") ;
String tomcat = path.substring(0,path.last IndexOf(re quest.getC ontextPath ()));
String path = getServletContext().getRea
String tomcat = path.substring(0,path.last
I'm not sure whether you are looking for this or not.
some.jsp
======
<%
String realPath = application.getRealPath("s ome.jsp");
%>
some.jsp
======
<%
String realPath = application.getRealPath("s
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this works for me:
String temp = System.getProperty("tomcat .home");
out.print(temp);
String temp = System.getProperty("tomcat
out.print(temp);
Yes, bobbit's code is easier.
ASKER
hmm, tomcat.home returns null for me...
but getServletContext().getRea lPath("/") ; return exactly what i wanted
but getServletContext().getRea