matthias wrote:
>
> Hy,
>
> please help me with this little problem.
>
> Everytime when i start a scriptlet "<%" the compiled Sevlet from this jsp
> includes a line break "out.write("\r\n");". Is it possible the avoid this
> behaviour.
JSP preserves whitespace, including line breaks. So for each JSP element
that's on its own line, you'll get a line break. To avoid line breaks in
the response generated by a portion of your JSP page, start the new element
on the same line as the previous element ends. For instance:
<% String foo = "bar"; %>
<jsp:setProperty name="x" property="y"
value="<%= bar %>" />
gives you two line breaks in the response: one for the line break after
the scriptlet end tag and another for the line break after the
<jsp:setProperty> tag. Note that the line break *within* the <jsp:setProperty>
tag is not added to the response. This is true for line break within any
JSP element, so it applies even to a multiline scriptlet.
To change this example so it only emits one line break, do this:
<% String foo = "bar"; %><jsp:setProperty name="x" property="y"
value="<%= bar %>" />
Here I have removed the line break after the scriptlet so only the one
after <jsp:setProperty> is added to the response.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets