1

My Tomcat servlet generate CSS from several patterns dynamically.

After CSS manipulations done, servlet return it.

I want minimize generated CSS.

What way I can minimize CSS before response?

  • Java routines
  • External library
  • Other

Sample of GET handler:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

StringBuilder cssContent = new StringBuilder();

/* Some CSS manipulations */

/* Now cssContent contain generated CSS. Lets return it. */

/* Minimize before response!!! - How? */

response.setContentType("text/css");
response.setStatus(200);
response.getWriter().write(cssContent.toString());

}
Dmitry
  • 877
  • 1
  • 16
  • 30
  • "_Which library I can use_" == off topic on this site. – Boris the Spider Jan 26 '17 at 16:33
  • https://developer.yahoo.com/yui/compressor/ has worked well for me in the past for static compressions. I've not used it dynamically but it is a Java program and should be able to be integrated into the servlet or a filter. – stdunbar Jan 26 '17 at 21:35
  • 1
    The following post from StackOverflow summarizes quite a few methods - http://stackoverflow.com/questions/1379856/how-do-you-automate-javascript-minification-for-your-java-web-applications – Mahesh Jan 29 '17 at 17:14

0 Answers0