Re: Whitespace generated by JSTL tags

2003-01-22 Thread matsuhashi

Martin Cooper wrote:
>It will also have a noticeable - and undesirable - effect on any 
>sections in the JSP page, causing them to be rendered incorrectly.

You are right. I also want  sections untouched. Hum...

A possible countermeasure could be to write a custom Ant task which does
the similar string relacement as the ant ReplaceRegExp task does while
caring in/out status of "PRE" start/end tags (very easy to write if in awk
:-). I will try this approach and come back here when finished.

 MATSUHASHI,kazuaki




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2003-01-22 Thread Martin Cooper


On Wed, 22 Jan 2003 [EMAIL PROTECTED] wrote:

>
> Hi,
>
> Corby Jacobs wrote:
> >1) whitespace the developer added to make the JSP more readable seems to
> be repeated in the HTML sent to the client (and duplicated >if it's inside
> a  tag)
> ...
> >My question is this:  Is there any way to avoid all this whitespace caused
> by core JSTL tags?
>
> I recently noticed that the Ant 1.5 added "ReplaceRegExp" optional task.
>
> My idea is (... haven't tried yet but will do soon) to filter the manually
> written JSP files by ReplaceRegExp task with the match="^\s*" replace=""
> attributes. This will chomp off the leading " " and "\t" chars in each
> lines for readablity, leaving newlines there. You can do this filtering
> when you replicate JSPs from the src dir to the build dir to create a .war
> file for deployment.
>
> I suppose this very low-tech (therefore, safe) code de-cosmetics will have
> noticeable effect for decreasing the size of the JSP response.

It will also have a noticeable - and undesirable - effect on any 
sections in the JSP page, causing them to be rendered incorrectly.

--
Martin Cooper


>
>
>  MATSUHASHI,kazuaki
>
>
>
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2003-01-22 Thread matsuhashi

Hi,

Corby Jacobs wrote:
>1) whitespace the developer added to make the JSP more readable seems to
be repeated in the HTML sent to the client (and duplicated >if it's inside
a  tag)
...
>My question is this:  Is there any way to avoid all this whitespace caused
by core JSTL tags?

I recently noticed that the Ant 1.5 added "ReplaceRegExp" optional task.

My idea is (... haven't tried yet but will do soon) to filter the manually
written JSP files by ReplaceRegExp task with the match="^\s*" replace=""
attributes. This will chomp off the leading " " and "\t" chars in each
lines for readablity, leaving newlines there. You can do this filtering
when you replicate JSPs from the src dir to the build dir to create a .war
file for deployment.

I suppose this very low-tech (therefore, safe) code de-cosmetics will have
noticeable effect for decreasing the size of the JSP response.


 MATSUHASHI,kazuaki



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Whitespace generated by JSTL tags

2002-11-14 Thread Martin Cooper


> -Original Message-
> From: peter lin [mailto:peter.lin@;labs.gte.com]
> Sent: Thursday, November 14, 2002 4:05 AM
> To: Tag Libraries Users List
> Subject: Re: Whitespace generated by JSTL tags
> 
> 
> 
> there were discussions a while back on this topic. I submitted a
> suggestion to the expert group for JSP requarding this issue for JSP
> compile filters.  Using compression is one fix, but it doesn't really
> address the heart of the problem. If you look at the generated source
> file, you will see tons of out.write for all those blank 
> lines.  It's a
> bit wasteful to have all blank lines, so there should be a clear
> specification on how JSP page compiler should remove extra spaces if
> application desires.
> 
> I had several discussions with the developers of Jasper2. The current
> spec states the whitespace and blank lines have to be preserved. I'm
> hoping the JSP spec after 2.0 will address this issue and make it a
> configurable. 

Yes, it would have to be configurable. A lot of people seem to assume that
JSP always generates HTML to it's safe to always collapse whitespace, but
that's not true, and whitespace sometimes matters.

--
Martin Cooper


> 
> peter
> 
> 
> Wolfgang Röckelein wrote:
> > 
> > Hi,
> > 
> > Hans Bergsten wrote:
> > > Anyway, the best way to handle it is probably to use a filter that
> > > compresses the response (most browsers supports 
> compressed responses
> > > today) since that would reduce the space needed for both 
> whitespace
> > > and repeated tags. See this article for an example of the 
> implementation
> > > of such a filter:
> > >
> > >   
> <http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html>
> > 
> > Has anybody used this filer with a recent tomcat Version?
> > 
> > I mostly get 0 length files from this filter (Tomcat 4.1.12) ...
> > 
> > Thank you for any hints,
> >Wolfgang
> > 
> > --
> > To unsubscribe, e-mail:   
> <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
> > For additional commands, e-mail: 
> <mailto:taglibs-user-help@;jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   
> <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:taglibs-user-help@;jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>




Re: Whitespace generated by JSTL tags

2002-11-14 Thread Dave Newton
Wolfgang Röckelein wrote:


I mostly get 0 length files from this filter (Tomcat 4.1.12) ...


So... the compression is working really, really well.

I suppose you're going to complain about the decompression now?

;)

Dave



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2002-11-14 Thread peter lin

there were discussions a while back on this topic. I submitted a
suggestion to the expert group for JSP requarding this issue for JSP
compile filters.  Using compression is one fix, but it doesn't really
address the heart of the problem. If you look at the generated source
file, you will see tons of out.write for all those blank lines.  It's a
bit wasteful to have all blank lines, so there should be a clear
specification on how JSP page compiler should remove extra spaces if
application desires.

I had several discussions with the developers of Jasper2. The current
spec states the whitespace and blank lines have to be preserved. I'm
hoping the JSP spec after 2.0 will address this issue and make it a
configurable. 

peter


Wolfgang Röckelein wrote:
> 
> Hi,
> 
> Hans Bergsten wrote:
> > Anyway, the best way to handle it is probably to use a filter that
> > compresses the response (most browsers supports compressed responses
> > today) since that would reduce the space needed for both whitespace
> > and repeated tags. See this article for an example of the implementation
> > of such a filter:
> >
> >   
> 
> Has anybody used this filer with a recent tomcat Version?
> 
> I mostly get 0 length files from this filter (Tomcat 4.1.12) ...
> 
> Thank you for any hints,
>Wolfgang
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2002-11-14 Thread Wolfgang Röckelein
Hi,

Hans Bergsten wrote:

Anyway, the best way to handle it is probably to use a filter that
compresses the response (most browsers supports compressed responses
today) since that would reduce the space needed for both whitespace
and repeated tags. See this article for an example of the implementation
of such a filter:

  


Has anybody used this filer with a recent tomcat Version?

I mostly get 0 length files from this filter (Tomcat 4.1.12) ...

Thank you for any hints,
  Wolfgang


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2002-11-14 Thread Þorgils Völundarson
I use a tag from the coldtags suit called optimize. It can be found here 
http://coldjava.hypermart.net/servlets/opttags.htm along with info.

Hope it helps,
Thorgils

I am investigating an issue with a JSP page which, under certain 
circumstances, generates a 22.4 MB file to send back to the client.  Turns 
out, a substantial portion of this page is whitespace.  As I see it, the 
whitespace is coming from two places:

1) whitespace the developer added to make the JSP more readable seems to 
be repeated in the HTML sent to the client (and duplicated if it's inside 
a  tag)

and

2) the tags themselves are generating extra newline characters

To address issue 1, I edited the JSP file, changed all tabs to one blank 
space, and removed all empty lines.  This reduced the size of the file 
from 22.4MB to 4.1MB.  Then, within the triple-nested  loops, I 
made the code all one line -- very ugly, but reduced the size of the HTML 
file to 367kB.

To confirm my suspicions on issue 2, I re-wrote a small excerpt of the 
page to use scriptlets instead of  and  tags.  The loop 
is used to generate a  with s whose value depend on the 
iteration through the loop.  As you can see in the excerpt from the "view 
page" source sent to the client, the version generated with the core JSTL 
tags has extra whitespace between the s.  Imagine doing this for a 
menu of 100 s, 3 times, and you can see where all the whitespace 
is coming from.  I tested this with both Tomcat and Weblogic as the web 
server.

My question is this:  Is there any way to avoid all this whitespace caused 
by core JSTL tags?






This selection menu was generated using standard JSTL tags 
, , and .








 
 HELP
 



 
 USER
 



 
 WRITE
 



 
 QUERY
 







This selection menu was generated using scriptlets instead of 
standard JSTL tags.






 
 HELP
 

 
 USER
 

 
 WRITE
 

 
 QUERY
 







Thanks,

Corby Jacobs
[EMAIL PROTECTED]
Convera Corporation
11000 Broken Land Pkwy
Columbia, MD 21044

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 


Kveðja,
Þorgils Völundarson
Krabbameinsfélag Íslands, Krabbameinsskrá
Beinn sími: 540 1973
netfang: [EMAIL PROTECTED]
gsm: 698 5302


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Whitespace generated by JSTL tags

2002-11-13 Thread Corby Jacobs
Thanks for explaining the origin of the extra empty lines.  I now see that the 3 lines 
between the s match up to the , , and  tags in the JSP 
I used to create the example (see below).

Thanks also for the direction to the filter example.  I will pass it along to the 
developer.

Perhaps this "preservation of whitespace" feature needs to be in the JSTL FAQ, along 
with the filter solution.  I didn't see it anywhere in my travels before I wrote to 
this list.

Thanks again.



 
This selection menu was generated using standard JSTL tags <c:if>, 
<c:forEach>, and <c:out>.



 


   
  
 " 
testID="option_wordNode_" >
 
 
  
   





-Original Message-
From: Hans Bergsten [mailto:hans@;gefionsoftware.com]
Sent: Wednesday, November 13, 2002 4:38 PM
To: Tag Libraries Users List
Subject: Re: Whitespace generated by JSTL tags


Corby Jacobs wrote:
 > I am investigating an issue with a JSP page which, under certain
 > circumstances, generates a 22.4 MB file to send back to the client.
 > Turns out, a substantial portion of this page is whitespace.  As I
 > see it, the whitespace is coming from two places:
 >
 > 1) whitespace the developer added to make the JSP more readable seems
 > to be repeated in the HTML sent to the client (and duplicated if it's
 > inside a  tag)
 >
 > and
 >
 > 2) the tags themselves are generating extra newline characters
 >
 > To address issue 1, I edited the JSP file, changed all tabs to one
 > blank space, and removed all empty lines.  This reduced the size of
 > the file from 22.4MB to 4.1MB.  Then, within the triple-nested
 >  loops, I made the code all one line -- very ugly, but
 > reduced the size of the HTML file to 367kB.
 >
 > To confirm my suspicions on issue 2, I re-wrote a small excerpt of
 > the page to use scriptlets instead of  and  tags.
 > The loop is used to generate a  with s whose value
 > depend on the iteration through the loop.  As you can see in the
 > excerpt from the "view page" source sent to the client, the version
 > generated with the core JSTL tags has extra whitespace between the
 > s.  Imagine doing this for a menu of 100 s, 3 times,
 > and you can see where all the whitespace is coming from.  I tested
 > this with both Tomcat and Weblogic as the web server.
 >
 > My question is this:  Is there any way to avoid all this whitespace
 > caused by core JSTL tags?
 > [...]

JSP _preserves_ whitespace, so it's not really accurate to say that
tags "generate" whitespace; what you see is the newlines after the
tags being preserved.

Anyway, the best way to handle it is probably to use a filter that
compresses the response (most browsers supports compressed responses
today) since that would reduce the space needed for both whitespace
and repeated tags. See this article for an example of the implementation
of such a filter:

   <http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html>

Another alternative is to use a filter that removes whitespace, but
that requires parsing of the response. You may be able to do it using
something like the W3C JTidy parser, assuming the HTML is basically
well-formed.

   <http://sourceforge.net/projects/jtidy>

Hans
-- 
Hans Bergsten<[EMAIL PROTECTED]>
Gefion Software   <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at<http://TheJSPBook.com/>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>




Re: Whitespace generated by JSTL tags

2002-11-13 Thread Hans Bergsten
Corby Jacobs wrote:
> I am investigating an issue with a JSP page which, under certain
> circumstances, generates a 22.4 MB file to send back to the client.
> Turns out, a substantial portion of this page is whitespace.  As I
> see it, the whitespace is coming from two places:
>
> 1) whitespace the developer added to make the JSP more readable seems
> to be repeated in the HTML sent to the client (and duplicated if it's
> inside a  tag)
>
> and
>
> 2) the tags themselves are generating extra newline characters
>
> To address issue 1, I edited the JSP file, changed all tabs to one
> blank space, and removed all empty lines.  This reduced the size of
> the file from 22.4MB to 4.1MB.  Then, within the triple-nested
>  loops, I made the code all one line -- very ugly, but
> reduced the size of the HTML file to 367kB.
>
> To confirm my suspicions on issue 2, I re-wrote a small excerpt of
> the page to use scriptlets instead of  and  tags.
> The loop is used to generate a  with s whose value
> depend on the iteration through the loop.  As you can see in the
> excerpt from the "view page" source sent to the client, the version
> generated with the core JSTL tags has extra whitespace between the
> s.  Imagine doing this for a menu of 100 s, 3 times,
> and you can see where all the whitespace is coming from.  I tested
> this with both Tomcat and Weblogic as the web server.
>
> My question is this:  Is there any way to avoid all this whitespace
> caused by core JSTL tags?
> [...]

JSP _preserves_ whitespace, so it's not really accurate to say that
tags "generate" whitespace; what you see is the newlines after the
tags being preserved.

Anyway, the best way to handle it is probably to use a filter that
compresses the response (most browsers supports compressed responses
today) since that would reduce the space needed for both whitespace
and repeated tags. See this article for an example of the implementation
of such a filter:

  

Another alternative is to use a filter that removes whitespace, but
that requires parsing of the response. You may be able to do it using
something like the W3C JTidy parser, assuming the HTML is basically
well-formed.

  

Hans
--
Hans Bergsten<[EMAIL PROTECTED]>
Gefion Software   
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Whitespace generated by JSTL tags

2002-11-13 Thread Stefan
Hi,


I too noticed the white space issue. Though it is not in the scale that you
described, it is a problem. It  has to be addressed as this will certainly
be the source of page bloat for unsuspecting people.

As a temp fix try using Gzip compression on the pages. This is the sort of
thing that I think GZIP can really help with.  I use a servlet filter that
does this automatically.

Stef



- Original Message -
From: "Henri Yandell" <[EMAIL PROTECTED]>
To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, November 13, 2002 4:17 PM
Subject: Re: Whitespace generated by JSTL tags


> really stupid answer
>
> but you could try wrapping it all in a string taglib which search and
> replaced for whitespace :)
>
> Hen
>
> On Wed, 13 Nov 2002, Corby Jacobs wrote:
>
> > I am investigating an issue with a JSP page which, under certain
circumstances, generates a 22.4 MB file to send back to the client.  Turns
out, a substantial portion of this page is whitespace.  As I see it, the
whitespace is coming from two places:
> >
> > 1) whitespace the developer added to make the JSP more readable seems to
be repeated in the HTML sent to the client (and duplicated if it's inside a
 tag)
> >
> > and
> >
> > 2) the tags themselves are generating extra newline characters
> >
> > To address issue 1, I edited the JSP file, changed all tabs to one blank
space, and removed all empty lines.  This reduced the size of the file from
22.4MB to 4.1MB.  Then, within the triple-nested  loops, I made
the code all one line -- very ugly, but reduced the size of the HTML file to
367kB.
> >
> > To confirm my suspicions on issue 2, I re-wrote a small excerpt of the
page to use scriptlets instead of  and  tags.  The loop is
used to generate a  with s whose value depend on the
iteration through the loop.  As you can see in the excerpt from the "view
page" source sent to the client, the version generated with the core JSTL
tags has extra whitespace between the s.  Imagine doing this for a
menu of 100 s, 3 times, and you can see where all the whitespace is
coming from.  I tested this with both Tomcat and Weblogic as the web server.
> >
> > My question is this:  Is there any way to avoid all this whitespace
caused by core JSTL tags?
> >
> >
> >
> > 
> > 
> > 
> > This selection menu was generated using standard JSTL tags
<c:if>, <c:forEach>, and <c:out>.
> > 
> > 
> > 
> > 
> > 
> >
> >
> >
> >  
> >  HELP
> >  
> >
> >
> >
> >  
> >  USER
> >  
> >
> >
> >
> >  
> >  WRITE
> >  
> >
> >
> >
> >  
> >  QUERY
> >  
> >
> >
> > 
> > 
> > 
> > 
> > 
> > This selection menu was generated using scriptlets instead of
standard JSTL tags.
> > 
> > 
> > 
> > 
> > 
> >
> >  
> >  HELP
> >  
> >
> >  
> >  USER
> >  
> >
> >  
> >  WRITE
> >  
> >
> >  
> >  QUERY
> >  
> >
> > 
> > 
> > 
> > 
> >
> >
> > Thanks,
> >
> > Corby Jacobs
> > [EMAIL PROTECTED]
> > Convera Corporation
> > 11000 Broken Land Pkwy
> > Columbia, MD 21044
> >
> > --
> > To unsubscribe, e-mail:
<mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:taglibs-user-help@;jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
<mailto:taglibs-user-help@;jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>




Re: Whitespace generated by JSTL tags

2002-11-13 Thread Henri Yandell
really stupid answer

but you could try wrapping it all in a string taglib which search and
replaced for whitespace :)

Hen

On Wed, 13 Nov 2002, Corby Jacobs wrote:

> I am investigating an issue with a JSP page which, under certain circumstances, 
>generates a 22.4 MB file to send back to the client.  Turns out, a substantial 
>portion of this page is whitespace.  As I see it, the whitespace is coming from two 
>places:
>
> 1) whitespace the developer added to make the JSP more readable seems to be repeated 
>in the HTML sent to the client (and duplicated if it's inside a  tag)
>
> and
>
> 2) the tags themselves are generating extra newline characters
>
> To address issue 1, I edited the JSP file, changed all tabs to one blank space, and 
>removed all empty lines.  This reduced the size of the file from 22.4MB to 4.1MB.  
>Then, within the triple-nested  loops, I made the code all one line -- 
>very ugly, but reduced the size of the HTML file to 367kB.
>
> To confirm my suspicions on issue 2, I re-wrote a small excerpt of the page to use 
>scriptlets instead of  and  tags.  The loop is used to generate a 
> with s whose value depend on the iteration through the loop.  As you 
>can see in the excerpt from the "view page" source sent to the client, the version 
>generated with the core JSTL tags has extra whitespace between the s.  
>Imagine doing this for a menu of 100 s, 3 times, and you can see where all 
>the whitespace is coming from.  I tested this with both Tomcat and Weblogic as the 
>web server.
>
> My question is this:  Is there any way to avoid all this whitespace caused by core 
>JSTL tags?
>
>
>
> 
> 
> 
> This selection menu was generated using standard JSTL tags , 
>, and .
> 
> 
> 
> 
> 
>
>
>
>  
>  HELP
>  
>
>
>
>  
>  USER
>  
>
>
>
>  
>  WRITE
>  
>
>
>
>  
>  QUERY
>  
>
>
> 
> 
> 
> 
> 
> This selection menu was generated using scriptlets instead of standard JSTL tags.
> 
> 
> 
> 
> 
>
>  
>  HELP
>  
>
>  
>  USER
>  
>
>  
>  WRITE
>  
>
>  
>  QUERY
>  
>
> 
> 
> 
> 
>
>
> Thanks,
>
> Corby Jacobs
> [EMAIL PROTECTED]
> Convera Corporation
> 11000 Broken Land Pkwy
> Columbia, MD 21044
>
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: