JSP gzip output

I know that I can gzip the output stream using something like ..


OutputStream outA = response.getOutputStream();
outWriter = new PrintWriter(new GZIPOutputStream(outA), false);      
response.setHeader("Content-Encoding", "gzip");
outWriter.println(.....);
outWriter.close();

in JSP, but is it possible to write it as:

OutputStream outA = response.getOutputStream ();
outWriter = new PrintWriter (new GZIPOutputStream (outA), false);      
response.setHeader ("Content-Encoding", "gzip");
%>
...

I know that this is done in PHP, for example, by grabbing the output buffer before flushing it, gzipping the buffer and then finally writing it.

But is this possible in JSP?

+3
source share
1 answer

This Java code is not owned by JSP.

gzip HTML, JSP, . JBoss ( Tomcat) compression <Connector> /server.xml on.

<Connector compression="on">

. text/* (HTML/CSS/JS).

. :

+4

Source: https://habr.com/ru/post/1788446/


All Articles