• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could the path of getResourceAsStream started without "/"?

 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,all

It was said that the parameter "path" of the getResourceAsStream(String path) of ServletContext should be specified according to the rules given in getResource in the J2EE API Specification. The specification said that the path of the getResource must begin with a "/" and is interpreted as relative to the current context root.

I wrote two servlet classes and found that the path of getResource must be started with "/" as description, but the path of the getResourceAsStream could be started without "/" either.

My code:


It run suceessfully.

So I wonder whether the path of the getResourceAsStream coule be started without "/". If it could be that, what is it mean? Which directory is the path interpreted?
 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there somebody who could answer it?
It puzzled me for several days.
Thanks!
 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me you already did the experiment, almost. So why not find out for yourself? Just change from getResourceAsStream to getResource and you'll get a URL that you can look at.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!