Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
However, no text is displayed on the page. I'm sure it has to do with the first character inside the <pre> tag is '<'. Is this a known issue? Is there a utility to convert '<' to the literal of '<' and '>' to the literal of '>'? Your prompt reply is greatly appreciated. [ September 24, 2003: Message edited by: verduka fox ] [ September 24, 2003: Message edited by: verduka fox ]
It most certainly has to do with the < character. As you have surmised you need to use the < entity. If the value is the result of a JSP substitution, it's easy to write a utility that converts character like <, >, & and the like to their entity references. I know of no standard Java class that performs this function. hth, bear [ September 24, 2003: Message edited by: Bear Bibeault ]
Bear, Thanks for your response. I thought that by using the pre tag that the contents of the tag were displayed exactly as written. For example, multiple spaces are not consolidated as a single space; they are all written as spaces. Therefore, I assumed that the other characters in the pre tag would be observed in the same manner. False assumption?
Yes, while the pre tag will preserve new lines and spaces, and render the content in a fixed-width font, you must still use character entities for special HTML characters such as the angle brackets and the ampersand. bear
Ok, so now I'm trying to develop a method to parse through a String, detect any ampersand or angle brackets and change them to the special values. This seems to work but doesn't seem very efficient. Is there a better way to implement this? I look for the ampersand first, since putting it last would find the ampersands in the special values for the angle brackets.
Dorothy and Shabbir, Thanks for your suggestions. Dorothy, I can't use the replace method because this method requires a char to be replaced with a char. I need a char to be replaced with a String (i.e. ;<' replaced with "<"). Shabbir, I'm using WebSphere Application Server 4.0.3 which only supports 1.3. Unfortunately, the replaceAll method is in 1.4. Do you have any other suggestions? One more question: On the same page as the code that I originally questioned is this code:
This displays without a problem. Is there a reason that the first caused a problem? Is it because the character after the < is a letter instead of a number that it causes a problem? Your suggestions are greatly appreciated.