You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "McCormack, Chris" <Ch...@littlewoods.co.uk> on 2004/01/28 11:19:39 UTC

White space problem

Hi all
I am using struts with jstl. I have a problem that is a bit annoying. 
In the navigation jsp on one of my sites I have 2 nested c:forEach tags that have c:if tags inside them. If a bean element meets the c:if condition 
it gets c:out to the page, if not the loop skips over it until all the outer c:forEach beans have been looped.

The problem is however when the c:if condition is not met a white line is written out by the c:forEach (ie one white line for each iteration regardless of the c:if condition). This ends up with a MASS of white space on the page. Is there anyway to stop the c:forEach writing out the white space ?

tia
Chris

***********************************************
This e-mail and its attachments are confidential
and are intended for the above named recipient
only. If this has come to you in error, please 
notify the sender immediately and delete this 
e-mail from your system.
You must take no action based on this, nor must 
you copy or disclose it or any part of its contents 
to any person or organisation.
Statements and opinions contained in this email may 
not necessarily represent those of Littlewoods.
Please note that e-mail communications may be monitored.
The registered office of Littlewoods Limited and its
subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB.
Registered number of Littlewoods Limited is 262152.
************************************************


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


Re: White space problem

Posted by Nicolas De Loof <ni...@cgey.com>.
You can use the <string:trim> tag from jakarta taglibs

Nico.



Hi all
I am using struts with jstl. I have a problem that is a bit annoying.
In the navigation jsp on one of my sites I have 2 nested c:forEach tags that have c:if tags inside them. If a bean
element meets the c:if condition
it gets c:out to the page, if not the loop skips over it until all the outer c:forEach beans have been looped.

The problem is however when the c:if condition is not met a white line is written out by the c:forEach (ie one white
line for each iteration regardless of the c:if condition). This ends up with a MASS of white space on the page. Is there
anyway to stop the c:forEach writing out the white space ?

tia
Chris

***********************************************
This e-mail and its attachments are confidential
and are intended for the above named recipient
only. If this has come to you in error, please
notify the sender immediately and delete this
e-mail from your system.
You must take no action based on this, nor must
you copy or disclose it or any part of its contents
to any person or organisation.
Statements and opinions contained in this email may
not necessarily represent those of Littlewoods.
Please note that e-mail communications may be monitored.
The registered office of Littlewoods Limited and its
subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB.
Registered number of Littlewoods Limited is 262152.
************************************************


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


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


Re: White space problem

Posted by James Mitchell <jm...@apache.org>.
Yes, same as with any tag or scriptlet.

<c:forEach ....
  ><c:if ...>

   </c:if
></c:forEach>



Of course, you could always use a servlet filter and replace all "\n+" with
"/n".


--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (cell)
AIM: jmitchtx
MSN: jmitchell@apache.org



----- Original Message -----
From: "McCormack, Chris" <Ch...@littlewoods.co.uk>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, January 28, 2004 5:19 AM
Subject: White space problem



Hi all
I am using struts with jstl. I have a problem that is a bit annoying.
In the navigation jsp on one of my sites I have 2 nested c:forEach tags that
have c:if tags inside them. If a bean element meets the c:if condition
it gets c:out to the page, if not the loop skips over it until all the outer
c:forEach beans have been looped.

The problem is however when the c:if condition is not met a white line is
written out by the c:forEach (ie one white line for each iteration
regardless of the c:if condition). This ends up with a MASS of white space
on the page. Is there anyway to stop the c:forEach writing out the white
space ?

tia
Chris

***********************************************
This e-mail and its attachments are confidential
and are intended for the above named recipient
only. If this has come to you in error, please
notify the sender immediately and delete this
e-mail from your system.
You must take no action based on this, nor must
you copy or disclose it or any part of its contents
to any person or organisation.
Statements and opinions contained in this email may
not necessarily represent those of Littlewoods.
Please note that e-mail communications may be monitored.
The registered office of Littlewoods Limited and its
subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB.
Registered number of Littlewoods Limited is 262152.
************************************************


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


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