My JSP page contains:
<script>
var bt_wd40_appurl = "${pageContext.request.contextPath}";
</script>
view/source shows "" for the value. No errors I've found so far.
my web.xml specifies version 2.5.
It will be empty if you deployed the webapp on ROOT. See also its javadoc (emphasis mine):
getContextPath
java.lang.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 "". The container does not decode this string.
Are you sure that you did deploy it on a context path? Note that the context path doesn't contain the scheme/domain part of the URL, it's a domain-relative URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With