Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"/" in context path

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

suppose the current servlet is deployed under the context root "/". What does HttpServletRequest.getContextPath(...) return?
My study guide says "", but I don't really understand why this isn't "/" ?
I quote:
... the context path never ends with a /, and therfore "/" maps to "".
.
I just can't follow that statement.

Kind Regards,
Andy
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,

That is just as it is defined in the API:
String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".


Regards,
Frits
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks Frits, so it's just a matter of definition in the API. I just couldn't follow the awkward explanation in my study companion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic