• Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying a resource path with SerlvetContext

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just one question: while it's true that the ServletContext.getRequestDispatcher("/foo.jsp") must start with a "/", is the same true when we invoke the ServletContext.getResourceAsStream("foo.jar")? I mean, shall the resource name start with a "/"?
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco,

From the J2EE API:
getResourceAsStream:
The path must be specified according to the rules given in getResource.


getResource:
Returns a URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.

 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!