Right, Pierre-Yves, but his classes are in the wrong place. They
should be in ../examples/WEB-INF/classes, not in ../servlets -
that's an HTML directory. By your suggestion:
static {
String path=
getServletConfig().getServletContext().getRealPath("/");
String servletPath = path + "/WEB-INF/classes/";
}
Cheers!
Mark
----- Original Message -----
From: "Saumont Pierre-Yves" <[EMAIL PROTECTED]>
Sent: Wednesday, April 18, 2001 5:52 AM
> 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-----
>
> 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,
___________________________________________________________________________
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