What do you mean exactly, when you say 'server path'? Given a URL of(for example) 'http://www.ugh.com:9023/happy/servlets/Fred?a=2&b=3' which maps to (say) /usr/loopy/web/myserver/happy/Fred.class which parts are you looking for?
Say that my server is located at c:\jswdk-1.0 and I am interested to access a file c:\jswdk-1.0\MyFolder\Myfile.xml. Is it possible to access it via ./MyFolder/Myfile.xml? I encoutered an error (needed protocol). Yours greenhorn, Adrian Muscalu
If you mean access the file using a browser, that all depends on where you have set the "document root" of your server. If you mean access the file from your server-side Java code, that all depends on where the "current directory" is set when you run your server. Or you could, of course, use a full path.
Frank seems to be right on. One other note, if you are getting errors about needing protocols, then you may be using the wrong classes to access the file. When accessing local files, all you need to do is give the path information (whether it be absolute or relative). Protocols do not come into play. Good Luck.
I think what you are looking for is the getRealPath method in the ServletContext class. Input to this method is the webserver's alias for a file, output is the real path which you can open a file to inside the servlet. WBB
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop