Say for example, you have a file style.css deployed in your context. The call to ServletContext.getResourceAsStream("style.css") returns an input stream. This is not correct behavior. The spec (2.3) says: > The path must be specified according to > the rules given in getResource. getResource() says: > The path must begin with a "/" and is interpreted > as relative to the current context root. My reading of these two things is that getResourceAsStream("style.css") should return null, not an input stream to the file. I got bit on this because my app behavior changed (broke) when ran on the current version of WebSphere.
Created attachment 20919 [details] test war Adding test war.
Created attachment 20920 [details] one way of fixing this Here's a simple patch which "fixes" the problem. getResourceAsStream can not throw an Exception (according to the spec), so I just return null. I'm ambivalent about this patch. This may create problems for some people who depend on the incorrect usage of this function. Plus, there may be a better solution, such as always returning an input stream containing "42"
Whilst I like the '42' idea, I am fairly sure not everyone else shares my sense of humour so null it will have to be. Patch applied to trunk and proposed for 5.5.x and 6.0.x. Many thanks for the patch.
Fixed in 6.0.x
Fixed in 5.5.x and will be included in 5.5.26 onwards.