users@glassfish.java.net

Re: Read file from docroot

From: yonestar <yoni_at_higtek.com>
Date: Thu, 8 Nov 2007 09:43:22 -0800 (PST)

Kedar, Jan, and others- thanks so much for the posts and discussion!! i've
tried some of your proposed solutions, but i'm not finding something that
works.

 it seems


> String pathString = ServletContext.getRealPath("/index.html");
> Could easily return:
> "C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\yourwar\index.html"
>

is exactly what i want. However, i cannot access the getRealPath method
("non-static method cannot be accessed from static context"). i think this
is b/c my program is not a servlet (does not extend any servlet
interface/class).

let me step back and describe again my goal. what i'm trying to do is:
when someone clicks a link, i will generate a file from DB and then return
that file to the user/browser. the way i was thinking of doing that was
having the link's event handler first create the file, and then navigate to
another page. that page would be the generated file or would re-direct to
the generated file.

my problem with the above is that the file i generate needs to be put in the
docroot. but, i may not know in advance the absolute path of the docroot (so
i don't know how to put the file there). a solution i'm considering for
this is using a properties file to store the docroot path. is there a
better way?

thanks!!
jon
-- 
View this message in context: http://www.nabble.com/Read-file-from-docroot-tf4738212.html#a13652044
Sent from the java.net - glassfish users mailing list archive at Nabble.com.