----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------


At 05:17 AM 6/7/00 +0700, you wrote:

>Hi all,
>
>Is there a way so my servlet can find the DocumentRoot of Apache server ?
>
>Thanks,
>
>Vu

In Jserv, the best you can do is call getRealPath() on the Request object.
(The pertinent source is copied below.)  As you can see, aliases and
virtual paths won't get translated, but you can get DcoumentRoot.

- Fernando

     /**
      * Applies alias rules to the specified virtual path and returns
      * the corresponding real path, or null if the translation can not
      * be performed for any reason.  For example, an HTTP servlet would
      * resolve the path using the virtual docroot, if virtual hosting
      * is enabled, and with the default docroot otherwise.  Calling
      * this method with the string "/" as an argument returns the
      * document root.
      * @param path The virtual path to be translated to a real path.
      */
     public String getRealPath(String path) {
         // FIXME: Make this somehow talk to Apache, do a subrequest
         // and get the real filename. Until then, we just tack the path onto
         // the doc root and hope it's right. *sigh*

         // DOCUMENT_ROOT is not a standard CGI var, although Apache always
         // gives it. So we allow for it to be not present.
         String doc_root = (String) env_vars.get("DOCUMENT_ROOT");

         if (doc_root == null) {
             return null;
         } else {
             return doc_root + path;
         }
     }



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to