views:

266

answers:

1

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?

+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
Okay. That was easy. :-) I thought request attributes and the variables in EL were unrelated ...
Thilo
@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