AEM 6.3 Dispatcher Cache and SlingHttpServletRequest set/getAttribute()
I've seen posts about issues using an HttpSession object for setting/getting attributes with AEM. Do those same issues apply to setting/getting attributes for a SlingHttpServletRequest? One post (non-Adobe) mentioned it affected Dispatcher caching, but not sure how reliable the source was. Another post mentioned receiving a new HttpSession on every request.
From a javax.servlet.Filter, we call slingHttpsServletRequest.setAttribute(), and from a Model class we call slingHttpServletRequest.getAttribute("key"), which is then accessed by HTL.
For instance, in the Filter:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
slingRequest.setAttribute("key", stringData);
...
And in the Model:
@Model(adaptables = SlingHttpServletRequest.class)
public class MyModel {
@Inject
private SlingHttpServletRequest request;
public String getMyData() {
String myData = (String) request.getAttribute("key");
...
Everything works fine accessing both Author and Publish directly (and of course, on our developer Author sandboxes). However, on Dispatcher, we don't see the attribute data. We've cleared Dispatcher cache twice, and are preparing to dig into the logs. But if there are known issues using request attributes, we can find another approach. Thanks for taking the time to look at this, and any helpful advice you can offer is much appreciated.
-Nestor