Hi,
I'd like to get the content of the generated WRO4J from a java servlet.
I need this because I want to calculate the hash of the content, and then distribute the file via an url: /hashed/$HASH/wro/style.css
The servlet that listens on /hashed/* gets the content from the original URL using a RequestDispatcher. Something like this:
RequestDispatcher dispatcher = context.getRequestDispatcher(plainUri);
ByteArrayResponseWrapper responseWrapper = new ByteArrayResponseWrapper(resp);
dispatcher.include(req, responseWrapper);
byte[] bytes = responseWrapper.getBytes();
String hash = SHA1Digest.toSHA1(bytes);
// if the calculated hash is the same as in the request uri then:
resp.getWriter().println(SHA1Digest.toSHA1(bytes));
resp.addHeader("Cache-Control", "max-age=" + SECONDS_IN_A_YEAR + ", public");
resp.addHeader("ETAG", hash);
....
(ByteArrayResponseWrapper is a custom class that gets the written content of the response accumulated into a byte array.)
This works for any static resources and also for servlet generated resources, but does not work for WRO4j as it creates the content using a filter.
How to get around this issue?
(I posted that myself, it's a different problem but both problems are caused by the same issue.)
Thanks,
T.