Use ServletContext.getResourceAsStream() and store the
XML file in WEB-INF/classes

Using a file path is very, very bad for web applications
as the web application may be deployed as a WAR where the
file path just doesn't exist, or it may be deployed into
an environment (such as a database) where a file path makes
no sense.

The Servlet specification is quite clear on this topic.
The only thing you can rely on is that you can deploy your
application as a WAR file, and that you can get access to
a temporary bit of filesystem via the javax.servlet.context.tempdir
context attribute.

Anything else you may want to do is application server
specific and therefore not portable.

Cheers,
	-- jon

Harsha Yalagach wrote:
Hi Andreas,
	That doesnt solve my problem as our client wants the application without
any configuration hassles and moreover the deployment platform is also not
specific. It may be deployed on win32 machines or Solarix machines or Linux
machines... :(

	Any more ideas...

Regards,
Harsha

-----Original Message-----
From: Andreas Probst [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 17:50
To: Tomcat Users List
Subject: Re: File Path Problem...


Hello,

maybe you could save the absolute path inside a properties file
or pass it as an init parameter in web.xml. For each location of
your app you would have to set this path appropriately. You
could use absolute paths and wouldn't need to change the source
code of the application.

Regards,
Andreas


On 21 Nov 2002 at 14:31, Harsha Yalagach wrote:


Hello,

I am running Tomcat 4.1 on Windows 2000 as a service.

   I have written a JSP page where in I am trying to read an
   XML. If I try
to access the file using absolute path, for eg. "c:\abc\xyz.xml",
the page works without any problem. But if i try to access it
thru relative path, for eg. "../data/xyz.xml", the tomcat will
throw a FileNotFoundException saying that xyz.xml doesnt exist in
SYSTEM-ROOT\System32 dir.

   The reason behind this is that the JSP is tring to access the
   file from
where JVM was started according to Java Documentation, ie
SYSTEM-ROOT\System32 directory where the Service Control Manager
starts the Tomcat service which in turn starts the JVM.

   So the question is, is there any other way I can use a
   relative path
inside my application to access a file? (I dont want to use
absolute path as my application has to be distributed in many
places).

Thanks in advance...
Warm Regards,
Harsha Yalagach


--------------------------------------------------------------
Cerebra Integrated Technologies Ltd., Bangalore, India



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]> For
additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>





--------------------------------------------------------------
Cerebra Integrated Technologies Ltd., Bangalore, India



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
Jon Eaves <[EMAIL PROTECTED]>
http://www.eaves.org/jon/


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to