You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Sidney-Woollett <jo...@wardbrook.com> on 2004/03/03 17:53:03 UTC

JSP whitespace removal

Hi

We want to achieve a 10-15% data reduction of the HTML being served by our
webserver (generated by JSP pages). This will have an impact on our
bandwidth charges from our ISP...

We can achieve this by by simply removing all the "\n\r", "\t characters
and replacing repeated occurences of "  " (double space) by " " (single
space). But we don't want to do this in our source JSP files as they will
become unmaintainable/unreadable.

eg
<table>
  <tr>
    <td>Column 1</td>
    <td>Column 2</td>
  <tr>
</table>

(69 characters)

becomes

<table><tr><td>Column 1</td><td>Column 2</td><tr></table>

(57 characters), that's an 17% saving for that text block...

I know that we could:

i) write/implement a filter to process the outputstream - BUT we use
OSCache (www.opensymphony.com) to cache (included) JSP pages, and we don't
want to reprocess cached data using another filter.

ii) use a script to transform or preprocess our JSP pages before they are
deployed - simple, but may have code breaking (between dev and live
system) or maintenance implications?

iii) create a tag library to process a text block (or another JSP), BUT
we've heard a rumour that taglibs can be inefficient (is that true?)

Question: is it possible to use a directive in a JSP page to force the
compiler to remove these characters to achieve our desired data reduction?

Are there any other techniques or solutions that anyone else is using?

Thanks

John Sidney-Woollett

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by Robert Krüger <kr...@signal7.de>.
I don't think that's what he's looking for. It merely trims the 
whitespaces between jsp-directives (i.e. newlines between taglib 
directives) which is not exactly the majority of whitespaces in 
realistic scenarios. I think what he's looking for is more like the 
result of outputting html through an xslt processor with no indenting 
and I don't think that exists for jasper.

Best regards,

Robert

> it trims the spaces during page compilation.
> make sure you blow away your work directory or otherwise edit your pages 
> so that they get recompiled.
> works really well for me.
> 
> -a
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 

-- 
________________________
Robert Krüger
Signal7 GmbH
Brüder Knauss Str. 79
64285 Darmstadt
Germany

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by Aadi Deshpande <ma...@clubmom-inc.com>.
bpsouther@adelphia.net wrote:

>On Wednesday 03 March 2004 05:33 pm, you wrote:
>  
>
>>consider using the trimSpaces option of the Jasper compiler in your
>>$CATALINA_BASE/conf/server.xml .
>>    
>>
>
>What, precisly does that do?
>
>I've tried it and seen no difference in the resulting HTML.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  
>
it trims the spaces during page compilation.
make sure you blow away your work directory or otherwise edit your pages 
so that they get recompiled.
works really well for me.

-a

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by bp...@adelphia.net.
On Wednesday 03 March 2004 05:33 pm, you wrote:
> consider using the trimSpaces option of the Jasper compiler in your
> $CATALINA_BASE/conf/server.xml .

What, precisly does that do?

I've tried it and seen no difference in the resulting HTML.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by Aadi Deshpande <ma...@clubmom-inc.com>.
consider using the trimSpaces option of the Jasper compiler in your 
$CATALINA_BASE/conf/server.xml .

-a

John Sidney-Woollett wrote:

>Hi
>
>We want to achieve a 10-15% data reduction of the HTML being served by our
>webserver (generated by JSP pages). This will have an impact on our
>bandwidth charges from our ISP...
>
>We can achieve this by by simply removing all the "\n\r", "\t characters
>and replacing repeated occurences of "  " (double space) by " " (single
>space). But we don't want to do this in our source JSP files as they will
>become unmaintainable/unreadable.
>
>eg
><table>
>  <tr>
>    <td>Column 1</td>
>    <td>Column 2</td>
>  <tr>
></table>
>
>(69 characters)
>
>becomes
>
><table><tr><td>Column 1</td><td>Column 2</td><tr></table>
>
>(57 characters), that's an 17% saving for that text block...
>
>I know that we could:
>
>i) write/implement a filter to process the outputstream - BUT we use
>OSCache (www.opensymphony.com) to cache (included) JSP pages, and we don't
>want to reprocess cached data using another filter.
>
>ii) use a script to transform or preprocess our JSP pages before they are
>deployed - simple, but may have code breaking (between dev and live
>system) or maintenance implications?
>
>iii) create a tag library to process a text block (or another JSP), BUT
>we've heard a rumour that taglibs can be inefficient (is that true?)
>
>Question: is it possible to use a directive in a JSP page to force the
>compiler to remove these characters to achieve our desired data reduction?
>
>Are there any other techniques or solutions that anyone else is using?
>
>Thanks
>
>John Sidney-Woollett
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by Peter Lin <tc...@yahoo.com>.
 
the reduction depends on your html right?
 
if you use a lot of tables, you're likely to see 5-10x compression. The easiest trick is to save a couple of your biggest pages and zip them up.  Compare the file size. Now, if you have regular log reports, you can see which pages get requested the most and how many bytes it is.
 
from that you can get a fairly accurate estimate in total bytes sent per week/month. Stripping out carriage returns and tabs most likely won't give you as much as compression.  Here is an easy way to test it on other sites.
 
Load a site that uses gzip with a browser that support gzip and without. Compare the actual bytes sent and how much faster the page loads. I know from first hand experience verizon SuperPages reduced 60K+ to 6K when they started using compression. The user's perception is the page was 2-4x faster. 
 
peter lin


John Sidney-Woollett <jo...@wardbrook.com> wrote:
Peter Lin said:
> have you tried turning gzip compression? that should produce similar
> bandwidth savings to stripping out extra carraige returns and double
> spaces.

We running Apache 1.3.x + JK + TC 5.0.x

What's better the gzip valve/filter in Tomcat, or try doing the
compression with an Apache module (if that's even possible for JSP
rendered pages)?

Also, is there a threshold below which the penalty for processing the
compression outweighs the data payload reductuion?

We want to be low bandwidth + responsive...

> you could always use the jasper plugin architecture to strip out excess
> stuff

Is there a link to some docs for this?

Thanks

John Sidney-Woollett

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster.

Re: JSP whitespace removal

Posted by John Sidney-Woollett <jo...@wardbrook.com>.
Peter Lin said:
> have you tried turning gzip compression?  that should produce similar
> bandwidth savings to stripping out extra carraige returns and double
> spaces.

We running Apache 1.3.x + JK + TC 5.0.x

What's better the gzip valve/filter in Tomcat, or try doing the
compression with an Apache module (if that's even possible for JSP
rendered pages)?

Also, is there a threshold below which the penalty for processing the
compression outweighs the data payload reductuion?

We want to be low bandwidth + responsive...

> you could always use the jasper plugin architecture to strip out excess
> stuff

Is there a link to some docs for this?

Thanks

John Sidney-Woollett

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: JSP whitespace removal

Posted by John Sidney-Woollett <jo...@wardbrook.com>.
Steffen Heil said:
> I cannot help you on this, but you should realise, that if you archive to
> reduce you jsps output by  10%, this will affect you traffic only by about
> 2%.
>
> We do have a server, which generated (according to access_log_*)
> 2.183.339.056 byte in 261.018 requests. But out provider counted about 9GB
> of traffic. [Actually he is accounting on switch port level and therefor
> including even ARP-requests, but anyway a lot of this traffic is based on
> out tomcat server.]

That's a good point - we're also charged at the switch port level!

We have a traffic shaper so we can control the amount of bandwidth
(Mbit/sec) we use for outbound traffic, and we're trying to cram as much
data per second as we can within our (managed/shaped) limit.

In fact it seems that (gzip) compression is a better strategy for HTML/CSS
pages because it offers compression of 80%. But it's still better to
compress the pages after you strip the whitespace for a small final text
size.

Unfortunately we also have a lot of graphics (but at least once they are
cached by the browser) then we only have to deal with a HEAD request to
see if they have been updated...

Thanks for the feedback.

John Sidney-Woollett

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP whitespace removal

Posted by Peter Lin <tc...@yahoo.com>.
have you tried turning gzip compression?  that should produce similar bandwidth savings to stripping out extra carraige returns and double spaces.
 
you could always use the jasper plugin architecture to strip out excess stuff
 
peter lin


John Sidney-Woollett <jo...@wardbrook.com> wrote:
Hi

We want to achieve a 10-15% data reduction of the HTML being served by our
webserver (generated by JSP pages). This will have an impact on our
bandwidth charges from our ISP...

We can achieve this by by simply removing all the "\n\r", "\t characters
and replacing repeated occurences of " " (double space) by " " (single
space). But we don't want to do this in our source JSP files as they will
become unmaintainable/unreadable.

eg


Column 1
Column 2



(69 characters)

becomes

Column 1Column 2

(57 characters), that's an 17% saving for that text block...

I know that we could:

i) write/implement a filter to process the outputstream - BUT we use
OSCache (www.opensymphony.com) to cache (included) JSP pages, and we don't
want to reprocess cached data using another filter.

ii) use a script to transform or preprocess our JSP pages before they are
deployed - simple, but may have code breaking (between dev and live
system) or maintenance implications?

iii) create a tag library to process a text block (or another JSP), BUT
we've heard a rumour that taglibs can be inefficient (is that true?)

Question: is it possible to use a directive in a JSP page to force the
compiler to remove these characters to achieve our desired data reduction?

Are there any other techniques or solutions that anyone else is using?

Thanks

John Sidney-Woollett

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

RE: JSP whitespace removal

Posted by SH Solutions <sh...@gmx.net>.
Hi

> We want to achieve a 10-15% data reduction of the HTML being served by our
webserver (generated by JSP pages). This will have an impact on our
bandwidth charges from our ISP...

I cannot help you on this, but you should realise, that if you archive to
reduce you jsps output by  10%, this will affect you traffic only by about
2%.

We do have a server, which generated (according to access_log_*)
2.183.339.056 byte in 261.018 requests. But out provider counted about 9GB
of traffic. [Actually he is accounting on switch port level and therefor
including even ARP-requests, but anyway a lot of this traffic is based on
out tomcat server.]

cu
  Steffen


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org