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 8 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.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database