Hi,
Your root document directory seems to be jswdk-1.0.1\examples\.
Your can access this directory with the following :
String path = getServletConfig().getServletContext().getRealPath("/");
you can then use the path string as the root document directory.
Please note that you must call this methods on your servlet object. You can
do it in the doGet or doPost method, but the path will only be available in
this method.
You can also use a member string :
public class MyServlet ..... {
String path;
public void doGet..... {
path = getServletConfig().getServletContext().getRealPath("/");
This way, the path will be usable in all methods.
You can also use a static initializer is you prefer to avoid setting the
variable for each method call. (The root document path probably won't change
between calls to the servlet !)
Also note that the trailing / is appended to the path by most
implementations. (One notable exception being Resin.)
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de Nik
DAMPIER
Envoyé : mercredi 18 avril 2001 11:21
À : [EMAIL PROTECTED]
Objet : servlet directory problems
Hello,
My name is Nikki DAMPIER,
I have down loaded jswdk-1.0.1 to use with my third year computer science
degree at leicester university. I.m have programmed a servlet that uses some
java classes(in the same dir as the servlet) which uses the DOM to read in
xml files and manipulates them by add customers to the XML file etc.
The problem I have, I think is quite a simple one, when the class that the
servlet has invoked runs any methods that try to read in an XML file I get
an error. I think this may be because I have not got the files in the right
place in the dir structure my servlet is in this folder:
jswdk-1.0.1\examples\WEB-INF\servlets\
but I don't know where to put the XML documents, so I was wondering if
someone could give me some help,
if you could email me back as soon as possible
at either,
[EMAIL PROTECTED] or
[EMAIL PROTECTED]
that would be much appreicated.
many thanks,
Nikki DAMPIER
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html