jQuery in Action, 3rd edition
The moose likes Tomcat and the fly likes Path to additional resources/xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Path to additional resources/xml file" Watch "Path to additional resources/xml file" New topic

Path to additional resources/xml file

Peter Jansen

Joined: Oct 30, 2006
Posts: 3
Hi, I've recently installed NetBeans and I'm having trouble with path information. NetBeans 5.5 RC2 installed a completely new version of Tomcat 5.5 on my local Windows system. Almost everything works fine. The default directory for my Project class files is "My Documents/ProjectName"

That's fine. But when I try to access an XML File from one of my servlets, netbeans-tomcat will look for it under netbeans-5.5rc2/enterprise3/apache-tomcat-5.5.17/bin and this is even on a whole different hard drive.

Of course I would prefer to have everything under one roof whithout using absolute paths. Where do I define my path for external files? It all worked fine before I used Netbeans, but then I had a different Tomcat 5.5 installation. As I said, Netbeans installs its own Tomcat version without even asking.

The funny thing is, when I access an image file from my jsp it will look in the same file system where the JSP is, but when I use the same JSP or a servlet to load my XML it will look for it elsewhere. Here is just a simple snippet of code to illustrate:

I tried to change some settings in Tomcat's configuration files, but it just didn't work.

Thanks for your help!!
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
That usage of File with the file name only just looks in the "current" directory, something you have no control over. You must use one of the versions of File that takes a path and provide for telling the application what the default path for this xml file is.

I agree. Here's the link: http://aspose.com/file-tools
subject: Path to additional resources/xml file
jQuery in Action, 3rd edition