aspose file tools*
The moose likes XML and Related Technologies and the fly likes Can't load XSLT file during init Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Can Watch "Can New topic
Author

Can't load XSLT file during init

Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
I'm trying to load my XSLT file during my servlet init. This line:
InputStream is = getServletContext().getResourceAsStream(xsltFile);

is giving me a null for the InputStream. Everything looks fine and I can see that xsltFile is the correct pathe to the file. I also tried to generate a URL using .getResource(xsltFile) and got a null for that. Is there some sort of registration or notification that I am missing?


Darryl Failla
Sun Certified Java 2 Programmer
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

No, what you are missing is that the getResourceAsStream() and getResource() methods don't expect to be passed the complete path to the file. They expect to be passed the path to the file, starting with a slash, relative to the web application's context root. (I got this information from the API documentation for the getResource() method of ServletContext.)
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
That did it. Thanks. I wish I would have come here two hours ago.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't load XSLT file during init