• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

tomcat 5.0 whitespace surgery

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys and gals
I have a client who is requesting that all the extraneous whitespace be removed from the JSP output on their site, believing it is adversely affecting bandwidth and search engine rankings.

I understand there are different settings in 5.5 and 6.0 to automatically do this but upgrading is not an option. So it seems the only way is to remove all newlines and indentation from certain JSP files.

Is there any way to configure an script to run on Ant deploy that automatically deletes all extra whitespace between JSP tag delimeters? We could do it before deployment but that would turn the page into a few very long lines, unmaintainable.

thanks
Sam
 
Sam Szabo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it seems the way to do this is add a block to the Ant build target like

<replaceregexp match="\s+" replace=" " flags="g" byline="true">
<fileset dir="${build.home}" includes="**/*.jsp"/>
</replaceregexp>

but I have not tested it yet. If anyone knows different I would appreciate it...
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JspServlet in Tomcat (which uses Jasper) has a trimSpaces parameter.
From tomcat/conf/web.xml:


This only prevents Jasper from inserting line breaks between actions and directives. It won't remove spaces that already exist in the JSP source.

As for bandwidth consumption,
You might want to look at the built in gzip capabilities that ship with Tomcat.
From tomcat/conf/server.xml:


I've never heard of whitespace affecting search engine ratings.
Is this something your client can demonstrate or are they just speculating?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have applied this requirement in my project also.
Pls follow the guidelines as i mentioned below
Try to search in the net to get trimfilter.jar jar file and place this jar file in your lib folder.
and add these tags in your web.xml file also.
<filter>
<filter-name>trimFilter</filter-name>
<filter-class>com.cj.trim.trimFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>trimFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>trimFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

otherwise mail your email address to [email protected] and i will send all the required files to you.
 
Get off me! Here, read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic