Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContext getResource(String path)

 
Zhiyong Sun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The path MUST begin with a "/" and is interpreted as relative to the current context root. This is defined in the Servlet API.
However, I tested this funciton without "/" and it still works fine. Also, in the example code from that Minning Published SCWCD Study Kit, it also did not use "/".
Can anybody clarify this?
 
Brusk Baran
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you reload the class then after having changed and re-compiled?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is well possible that some servlet engines are more lenient than the specification. Does it matter?
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic