JSP Document/JSPX: what determines how space/linebreaks are removed in the output?

Posted by NoozNooz42 on Stack Overflow See other posts from Stack Overflow or by NoozNooz42
Published on 2010-05-29T12:48:17Z Indexed on 2010/05/29 12:52 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

I've got a "JSP Document" ("JSP in XML") nicely formatted and when the webpage is generated and sent to the user, some linebreaks are removed.

Now the really weird part: apparently the "main" .jsp always gets all its linebreak removed but for any subsequent .jsp included from the main .jsp, linebreaks seems to be randomly removed (some are there, others aren't).

For example, if I'm looking at the webpage served from Firefox and ask to "view source", I get to see what is generated.

So, what determines when/how linebreaks are kept/removed?

This is just an example I made up... Can you force a .jsp to serve this:

<body><div id="page"><div id="header"><div class="title">...

or this:

<body>
  <div id="page">
    <div id="header">
      <div class="title">...

?

I take it that linebreaks are removed to save on bandwidth, but what if I want to keep them? And what if I want to keep the same XML indentation as in my .jsp file?

Is this doable?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsp