relative file path

A

Asad

I have a JSP located at:

G:/tomcat4/webapps/reportmanager/foo.jsp

Inside this jsp file I have this scriptlet:

<%
File Name= new File("G:/tomcat4/webapps/reportmanager/WEB-INF/classes/sample.xml");
if(!Name.exists())
{
%> sample.xml does not exist <%
}
else
{
%> sample.xml exists! <%
}
%>

Now I want to use relative filepath, but I am unable to do that. I
tried the following instead of the path indicated above but none of
these seem to work:

/WEB-INF/classes/sample.xml
../WEB-INF/classes/sample.xml
WEB-INF/classes/sample.xml

Note, once again that foo.jsp is located at
G:/tomcat4/webapps/reportmanager/foo.jsp itself.

Any ideas?

Thanks.
 
A

Asad

Try that where? Inside my jsp? I don't believe this has anything to do
with my problem; which was that I did not want to place sample.xml in
the same folder as my JSP. And if I placed my xml file in some other
folder, then the relative path to that location wasn't working.

So what are you suggesting!?
 
A

Andrew Thompson

in message
Given the directory structure, this may work better..

servletContext.getRealPath("/WEB-INF/classes/sample.xml);

HTH
 
A

Asad

Andrew Thompson said:
(chuckles) How silly of me.. It was *supposed*
to be a link, to a post that answered the question
- see my other post.

And please do not top-post..
<http://www.physci.org/codes/javafaq.jsp#netiquette>

And you still didn't give me the link that supposedly solved my
problem! But that's ok. I figured it out by printing absolulte and
relative paths. My servlet was running inside the bin directory and so
I had to move back one step to the parent and then give the path.

HTH anyone else who's going through the same problem.

Asad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top