Because of all the escaping problems, I think a separate action is the best solution for this instead of trying to do some tricks with the replace action. How about something like this:
<str:htmlEscape [nls="true|false"] [blanks="true|false"] [tabs="true|false" [tabLength="noOfChars"]]> text to be converted </str:htmlEscape> nls: replace all \n with <br> blanks: replace multiple blanks with , but leave single blanks alone tabs: replace tabs with a number of tabLength: how many characters a tab represents (default is 8) The "blanks" and "tabs" replacements make it possible to handle simple formatted (indented) text. Other replacements are possible, of course, such as "*" to "<li>", but this is a start. Hans Henri Yandell wrote: > > On Tue, 17 Sep 2002, zze-JEANJEAN S ext FTRD/DMI/SOP wrote: > > >>>>Is there a tag to convert \n to <br/> ?? >>> >>>You should be able to use the String Taglib or the Regexp Taglib. >>> >> >>The str:replace tag is not easy to use : in the replace propertie the \n >>is not understood :(( You have to put in this propetie a real new line, >>so the code is not really readable :( >>For instance : >>... >><str:replace replace=" >>" with="<BR/>"><c:out >>value="${requestScope[theKey].address1}"/></str:replace> >>... > > > Yeah. This needs to be solved doesn't it. > > Solutions: > > Make replace accept \n as being a newline. This would be doable, but what > if someone wanted to replace a \n sequence? Is it acceptable to make > 'tabs' illegal in the replace etc. Probably not. > > Add a replaceJava attribute, for specifying the replace tag as a Java > attribute. Would want a withJava attribute too. > Or maybe this is an encoding="java" attribute. > > Have a replaceNewline tag. A bit weak as you won't be able to replace > something with a newline in. Also has weaknesses as I'm trying to collate > similar functionality and not create more tags. > > ==== > I seem to recall that there are no XML character entities that work > there, but possible I could make one work. Whether this would be > cross-server though, I don't know. > > Most people will want \n to work I imagine, and won't care that they have > to do \\n to replace a \ and a n. If I change it so that all > String attributes get unescaped for Java entities, and maybe even all > content as well. I wonder if this will hurt anything... > > If not, I'll aim for this feature to be in a 2.0 release. My apologies for > not being able to get it in sooner. > > Hen > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- Hans Bergsten [EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com JavaServer Pages http://TheJSPBook.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>