Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

removing white spaces from JSP for faster loading?  RSS feed

 
Martin Habicht
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
does anyone has experience with removing unnecessary white spaces from a JSP? I thougth of running a little utility tool in my build process, that makes the JSP smaller. Looking at Google's HTML, they seem doing something similar...
Has anyone done this yet? Do you know a neat tool?
-Martin

PS: for those who really like whitespaces, check out this:
white space programming language
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo Martin,
afaik new apache versions come with mod_gzip
that checks whether the browser accepts gzipped data. If so, it send the html-output of e.g.
jsp or servlets gunziped.
I assume this is what google uses.
cb
 
Peter Daly
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christan,
Maybe, but not quite. While Google may use gzip (I don't know), that is not how they get rid of spaces.
It is my understanding that part of google's "programmer specifications" (for lack of a better term) is nothing on the page that does not need to be there...right down to spaces. Spaces are removed before the page is deployed to production. It has to do with their whole quality mindset that many other searchengines seem to lack.
This is performed on the pages themselves on the server, not as the page is being sent, which is the way gzip works.
-Pete
 
Martin Habicht
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter, you've got my point!
not that I want to make a second google, but I'm working on a web app... and as we all know they are usually kind of slow. There are certainly a lot to say about optimization and this would fill its own category...
Anwyay, I thought with this idea I could speed up all pages by just adding one more step in the build script. And I see that many or our pages contain about 33% white spaces. So I was wondering, whether the additional overhead for SSL encription, maybe a few IP packages more, their SSL decription and client-side parsing would have a measurable influence on the performance of the web app.
And since google is in general faster than many other pages, I thought this might be part of it. But I'm open too all ideas!
-Martin
 
Nigel King
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin,
Did you ever get a solution for this? I would like to do the same thing and mod_gzip is not available on my server.

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin last posted on JR in 2003, so there's not much point in asking him in this old thread. But to answer your question, in Tomcat 5.0+ you can get rid of whitespaces in your webapp by adding the following init parameter to the servlet declaration of the JspServlet in $CATALINA_HOME/conf/web.xml:

<init-param>
<param-name>trimSpaces</param-name>
<param-value>true</param-value>
</init-param>

You can also use compression in Tomcat as outlined here.

If you use some other servlet container that doesn't have these options, then it's quite simple to write a servlet filter that strips out the white space explicitly.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Habicht, in past we have got lots of performance improvement after removing white space and compressing the response.

All the best !
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and one more time
Martin posted his question almost 3 years ago.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two Servlet Filters Every Web Application Should Have
 
Nigel King
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for these replies. Exactly what I was looking for.
As for not noticing the original post was so so old ...
... sorry!
 
Martin Habicht
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

nice surprise to hear a feedback after so long! I'm glad to hear the idea works and is quite simple using filters.

Just because I haven't been posting that frequently doesn't mean I'm dead! ;-)


- Martin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!