henry human wrote:
> Hi David, thanks for your answer. Let say the scenario is a little different 
> from my first mail. I am not going to download the xsd file by client. I m 
> using a entity resolver inside a JAVA class to resolve a xsd resource inside 
> the WEB-INF/xsd directory. There are two ways to access a resource in my case
> 1) ask for absolute path
> 2) ask via getResourceAsStream
> 3) Ask for URL
>
> => 
> The point one is out of discussion, because on server it is not possible to 
> ask for absolute path :)
> The point two is the usual way to access resources inside a war file on a 
> server, but it did lead to the same result as one in my case!!!!
> The point three maybe resoolve my problem !
> Hier is my Resolver where you see where i call for the xsd:
> ***************************************************************
> public class MyEntityResolver extends DefaultHandler  implements 
> EntityResolver
>      {
>          public InputSource resolveEntity(String publicId, String systemId)   
>        {
>                   
> ......                                
>              if( systemId != null && systemId.endsWith(".xsd") )
>              {
> String xsdURL="http://myServer:5200/MyWebApplication/xsds/cusomer.xsd";;
>                       InputStream inputStream = 
> MyClass.class.getResourceAsStream(xsdURL);
>                       }
>               }
> ........
>       }
>
>
>
>
>  
>
>
> which expect a URL as systemId to find out a xsd file.  
>
>   
With the method you have, just store the xsds in the
WEB-INF/classes/xsds folder and then reference them by chopping off the
beginning 'http://myserver:5200/MyWebApplication part of the string'. 
Then getResourceAsStream should have no problem finding your xsds file.

Alternatively if you have access to the webapp's ServletContext
instance, you could use it's getResourceAsStream which can return an
input stream for any file in the webapp, not just what's in jars in
WEB-INF/lib or loose in WEB-INF/classes.  In that case, you'd chop off
up to and including MyWebApplication from the xsd url and replace it
with "/WEB-INF" assuming you've collected all the xsds in WEB-INF/xsds.

--David

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to