This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat 5.0 whitespace surgery

 
Sam Szabo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
B Sridhar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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 bsridhar@cybage.com and i will send all the required files to you.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic