Solved

HOWTO: preserve whitespace in a JSP document

Posted on 2006-07-04
3
1,279 Views
Last Modified: 2012-08-13
This is one of those, you know, or you don't know type of questions, not much of a change on just 'finding' it it seems.
First of, I'm talking about JSP documents, not pages, SUN has clarified this as a difference between xml-valid jsp pages and just plain old-school jsp pages. I'm talking about xml-valid here. In xml the general concensus is to strip all non-essential whitespace while processing a document. Now this is usually not a problem except that I have a desire to debug the output of my document and I would like it to remain human-readable.

From what I found out xml is supposed to have this preserved attribute that is supposed to be valid on all elements, 'xml:space="preserve"'. I'm saying supposed as eclipse is quite happily ignoring you if you add a space='preserve' to any given element, but starts slapping you on the wrist if you add xml:space. Tomcat really gets pissed with you for defining either of them.

So, with the default xml whitespace preservation out of the window, the question remain, how do I preserve whitespace in my JSP-document?
0
Comment
Question by:mreuring
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
ss_p earned 234 total points
ID: 17042115
you can write you own tag for preseving the whitespaces
0
 
LVL 17

Author Comment

by:mreuring
ID: 17048794
The content of the tag would still need to be parsed, how would I direct the parser to preserve the whitespace?
0
 
LVL 17

Author Comment

by:mreuring
ID: 17059059
Hmmm, for now I've resorted to using the jsp:text tag, which is far from preferable, but sorta does what you suggested.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question