Forums Register Login

pre tag causes text not to appear?

+Pie Number of slices to send: Send
Hello,
I have the following code displayed:

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 '&lt;' and '>' to the literal of '&gt;'? Your prompt reply is greatly appreciated.
[ September 24, 2003: Message edited by: verduka fox ]
[ September 24, 2003: Message edited by: verduka fox ]
+Pie Number of slices to send: Send
It most certainly has to do with the < character. As you have surmised you need to use the &lt; 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 ]
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Verduka - take a look at the String class' "replace" methods - you can probably handle this in one or two lines of code.
+Pie Number of slices to send: Send
Are you searching for following type of code

[ September 24, 2003: Message edited by: Shabbir Rahman ]
+Pie Number of slices to send: Send
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 "&lt;"). 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.
+Pie Number of slices to send: Send
The following is the replaceAll code of String class of 1.4

So you can easily use the following code in your class

Before doing that you need to import java.util.regex.Pattern. I don't know whether 1.3 has regular expression package or not.
[ September 24, 2003: Message edited by: Shabbir Rahman ]
+Pie Number of slices to send: Send
 

I don't know whether 1.3 has regular expression package or not.


It does not. To use regular expressions under 1.3 you might want to check out the Jakarta regex project. I use it regularly.
hth,
bear
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2951 times.
Similar Threads
IE 6.0 problems
URL parameter ~~howto ?
Funny innerHTML behavior
Close, but no cigar!
WSAD 5 XML/XSL Validator
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:47:07.