Paul Clapham wrote:
S Gibbs wrote:Hi Guys,
I'm really banging my head against a wall with this one, and was hoping someone could poke me in the right direction. I'm trying to parse xml using x:parse and the like. However I only ever get returned:
Now my understanding is that this implies that tomcat cannot see the classes involved.
No, that's wrong. It just means that the toString() method of a Document object returns that string. So it tells you that you have successfully created a Document object. As you can see it doesn't tell you anything more about that Document object; you would have to write other code to do that.
Originally posted by Ulf Dittmer:
Using the getClass.getResource method you can't access anything outside of the classes directory. It uses the classloader, which -no surprise there- only knows about things in the classpath.
Is there a particular reason you want to use Image.getInstance? The customary way to load images these days is javax.imageio.ImageIO.read (which can load images from everywhere, because it doesn't rely on classloaders).
Originally posted by Sravan Kumar:
1. The reason you are not able to move it out of WEB-INF/classes is because you use:
this.getClass().getResource
This obvioulsy looks for the resource in the context of the current class, which is the WEB-INF/classes folder.
2. The ideal way to read these resources (like images) in a web application is to use getServletContext().getResource() method. That way, you can place the images under your webapp context instead of WEB-INF/classes folder.
You might want to check out if there is a way of making the ServletContext object available in this class where you are loading images or if there is a way to get the image in a servlet class and making it available here.