[opencms-dev] Stupid New Lines

Jason Trump jason.trump at brulant.com
Thu Dec 15 17:04:35 CET 2005

this is a general problem with JSP; JSP can't efficiently tell which \n can be stripped out of your code, and which can.  there are two things you can do:

1.  install a white-space stripping servlet filter.  this is tricky and generally inefficient to implement and i wouldn't recommend it.  there are lots of examples of this on the internet.

2.  code your JSPs to remove the whitespace using JSP comments and careful placement of scriptlets, for example:

    DO NOT:
                 ... my code here ...

       <c:someTag>... my code here ...</c:someTag>

              --%>... my code here ...<%--

If you are using scriptlets, open the scriptlet declaration as soon as possible and close it as late as possible to avoid unwanted whitespace.  For example

    DO NOT:

    <p>some html code here
        scriptlet code logic here ...
    more html code here</p>


    <p>some html code here <%

        script code logic here ...

    %> more html code here</p>

you'll notice that most of the JSPs that ship with OpenCms are written in this style.


-----Original Message-----
From: opencms-dev-bounces at opencms.org on behalf of Anatol
Sent: Thu 12/15/2005 10:42 AM
To: The OpenCms mailing list
Subject: [opencms-dev] Stupid New Lines
Hi All!

For every JSP-Tag ( <cms:xxxxxxx > ) I got a new line in HTML-Code (not 
a <br>, but a \n !). If I use a cms:contentload Tag and the 
cms:contentshow, there were many stupid new lines generate :-(
How can I suppress these new lines? Any idea?

best regards

This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3331 bytes
Desc: not available
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20051215/f9f46e97/attachment.bin>

More information about the opencms-dev mailing list