Reputation: 48236
${response}
is null
${pageContext.response}
seems to belong to sitemesh filter.
I am trying to conditionally add the "manifest" attribute to the html tag depending on whether a response cache header is present or not.
UPDATE:
Brain-fart on my part. I was trying ${pageContext.response.header['Cache-Control']}
while the correct way is ${pageContext.response.getHeader('Cache-Control')}
Upvotes: 3
Views: 7452
Reputation: 1338
Here is a very straightforward example on accessing response headers: http://www.devmanuals.com/tutorials/java/jsp/getHeader.html
So I think these should both work:
<%
pageContext.setAttribute("cacheHeader", response.getHeader("cacheHeaderIamLookingFor"));
%>
<c:if test="${!empty cacheHeader}">
... add your manifest stuff ..
</c:if>
I believe this should also work:
<c:if test="${!empty pageContext.response.getHeader('cacheHeaderIamLookingFor')}">
... add your manifest stuff ..
</c:if>
Upvotes: 3