users@glassfish.java.net

Re: How to get the current path of my web application

From: yonestar <yoni_at_higtek.com>
Date: Wed, 13 Feb 2008 07:31:35 -0800 (PST)

I had a situation where i needed to load a file from the domain's docroot
(i.e. glassfish/domains/domain1/docroot)

This code provides the path of the docroot, and then you can just append the
file name:

/**
     * Get path of the docroot, regardless of where project is deployed
     * @return docroot path
     */
    private static String getDocRoot() {
        File docroot1 = new File("../docroot");

        try {
            docroot1 = docroot1.getCanonicalFile();
        } catch (IOException e) {
            docroot1 = docroot1.getAbsoluteFile();
        }
        return docroot1.getPath() + "\\";
    }
-- 
View this message in context: http://www.nabble.com/How-to-get-the-current-path-of-my-web-application-tp15455016p15459599.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.