views:

152

answers:

1

If this is the wrong approach, please suggest something better, but my current efforts have been trying to find something that exists for a single page load, such that I can cache which javascript/css files have been included so as to only include them once. I thought in a TagSupport subclass I could use

(HttpServletRequest)pageContext.getRequest().getParameterMap().put(srcKey,true)

but the request is per jsp, not per page load so it was a failure. I could set up a filter in web.xml, but it seems I would have to search the response for duplicates and rewrite the response...pain. I could try to store things in the session, but there are headaches with clearing values... Any help would be appreciated.

A: 
Pointy
I'm too new to this to argue with you. I'm just going to tell you what I'm seeing and hopefully you can show me what I'm missing. When entering doStartTag if I, for example, log pageContext.getRequest().getRequestURI()it reports back the name of the jsp that's being requested. If I setAttributes, or put via getParameterMap() the attributes and parameters seem to be new sets when req.getRequestURI starts reporting a new jsp. As a result, if I have two different jsps that try to include, say prototype.js, I get it twice on the page. Thoughts?
Felix
@Felix I've updated my answer - I don't understand exactly how your pages work
Pointy
The subsequent requests are a result of <jsp:include page="someFile.jsp" /> <%-- includes script.js %--><jsp:include page="otherFile.jsp" /><%-- also includes script.js %-->According to tools like Chrome's Web Inspector and FF's firebug, there's only one actual HTTP request for the page,namely actionName.do.If that's not enough information, I apologize, and I'll have to poke around some more before restating the question. Thanks for your time thus far.
Felix
Well if that is the case then the URI would not be changing. The URI remains the same across a request regardless of the JSP includes you do.
Pointy