Let JSF put it into the session using an autogenerated and unique key, pass that key as a request parameter or pathinfo to the servlet, and finally let the servlet remove it from the session using the key and use it.
JSF bean (during initialization or action):
this.key = UUID.randomUUID().toString(); externalContext.getSessionMap().put(key, object);
JSF view:
<h:graphicImage value="servleturl?key=#{bean.key}" />
Servlet:
String key = request.getParameter("key"); Object object = request.getSession().getAttribute(key); request.getSession().removeAttribute(key);
source share