Some frameworks (Spring, Tomcat itself) add servlet request attributes that cannot be used within an EL expression by default. An example would be
javax.servlet.forward.context_path = /myWebapp
So, to get the value using JSTL I'd normally use
<c:out value="${javax.servlet.forward.context_path}" />
However that's not working because the EL parser expects javax
to be the key of object A and servlet
to be a property of that object (and so on).
So my question is: How do I escape the dot character?
I've tried using
<c:out value="${javax\.servlet\.forward\.context_path}" />
but that's not working either and raises an error from the EL parser.
I know that when dealing with maps I can use something like
<c:out value="${aMap['key.from.map.with.dots']}" />
but thats not working with a first level object from the request, since I've also tried using
<c:out value="${['javax.servlet.forward.context_path']}" />
which is not working either.
Any ideas?
if you know the scope of the attribute, then you can fetch it from the appropriate implicit object, e.g.
${requestScope['javax.servlet.forward.context_path']}
I'm not sure if there's an implicit object that checks all scopes in the way that {xxx}
does, though.
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