Get real path of directory within WAR file

Hi,

I have an application that uses dtds for xml parsing. The dtds are all located in the WEB-INF/lib/dtd folder. I want to get the real path of this dtd folder so that I can pass this to the DocumentBuilder.parse method.

In the below code snippet, DTD_DIR is what I am trying to figure.

DocumentBuilder db = dbf.newDocumentBuilder();

Document doc = db.parse(inputStream, DTD_DIR);

The application is packaged as a WAR file. I tried

ServletContext().getResource( "/WEB-INF/lib/dtd/ " ). However this URL does not work. The DocumentBuilder is trying to resolve the following location:

/home/testApp/dist/testApp.war!/WEB-INF/lib/dtd/Get_List.dtd

Am I having somethign wrong in the above URL?

Thanks in advance.

With regards

Ganesh

[811 byte] By [pgakua] at [2007-10-2 0:40:42]
# 1

Hi

I resolved this problem. I added jar:file:

at the front to the path returned by

getServletContext().getResource("WEB-INF/lib/dtd").toString()

My path would now be

jar:file:/home/testApp/dist/testApp.war!/WEB-INF/lib/dtd/

This works.

Thanks a lot.

With regards

Ganesh

pgakua at 2007-7-15 16:55:37 > top of Java-index,Java Essentials,Java Programming...