You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jacob Kjome <ho...@visi.com> on 2003/04/01 16:43:30 UTC

Re: Can Tomcat (Servlet) read the DocumentRoot from an Apache web server?

Are you running out of the ROOT directory?  If so, then that is 
correct.  The real path of "/" is relative to your context so it would give 
you the absolute path to the root of your context, whichever context that 
is....that is if you are running from a directory and not directly from a 
.war file, in which case getRealPath() would return "null".

Jake

At 09:56 PM 3/31/2003 -0800, you wrote:
>Hi,
>
>I have Apache and Tomcat hooked-up using the mod_jk connector. I was
>wondering if Tomcat (or a Java Servlet running on Tomcat) is able to
>read the DocumentRoot of the Apache web server. I used the following
>code in my Servlet:
>
>String doc_root = getServletContext().getRealPath("/");
>out.println("doc_root = " + doc_root);
>
>but doc_root comes out as the Tomcat ROOT directory path, and not the
>Apache DocumentRoot path. Is what I am looking for even possible? I know
>there are ways, but most of these involve hard-coding the path in
>Tomcat's config files (virtual host definitions and stuff like that).  I
>am trying to avoid hard-coding the path anywhere in Tomcat.
>
>Thanks,
>
>Steve Cromer
>scromer@earthlink.net
>c380327@hs1004.lgb.cal.boeing.com
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org