How can I put an attribute into the JSP PageContext for the current request (so that it becomes accessible via ${myVar}
) from a Filter that runs before the JSP?
views:
266answers:
1
+1
A:
I think I may be missing something, but:
- you have the
ServletRequest
object in the filter - call
request.setAttribute("myVar", value);
- call
chain.doFilter(request, response);
Bozho
2010-02-11 06:14:41
Okay. That was easy. :-) I thought request attributes and the variables in EL were unrelated ...
Thilo
2010-02-11 06:36:13
@Thilo: `${foo}` does behind scenes `pageContext.findAttribute("foo")` and see what its javadoc says ;) http://java.sun.com/javaee/5/docs/api/javax/servlet/jsp/JspContext.html#findAttribute%28java.lang.String%29
BalusC
2010-02-11 11:25:39