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 "/" ?
... the context path never ends with a /, and therfore "/" maps to "".
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 "".
posted 6 years ago
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.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads