You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barett McGavock <bm...@pulvertech.com> on 2003/12/18 01:18:57 UTC

RE: Best way to parse a String and replace line feeds with
f or html?

Thoughts:
1) Assuming that you have a separate value object to carry this 
item to the view, try replacing any "\n" with "<br>" in the action.
2) Have you also considered using the <pre> HTML tag?

B

-----Original Message-----
From: David Erickson [mailto:derickson@cmcflex.com] 
Sent: Wednesday, December 17, 2003 5:05 PM
To: Struts Mailing List
Subject: Best way to parse a String and replace line feeds with <br> for
html?


Situation:
using the html:textarea element tag to enter notes on an object, thats
getting persisted as a blob in our database.  I would like to be able to
output this to html with the same formatting.. ie the line feeds work. Whats
the best way to do this?  I tried the jstl:core c:out tag and it didnt work
(did not goto the next line), tried the struts bean:write tag same problem.
Is there another struts tag library I can use? Thanks, David

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Best way to parse a String and replace line feeds with
for html?

Posted by David Erickson <de...@cmcflex.com>.
Barett:
Thanks for the tips.. I completely forgot about #1, and I think I will
implement #2 as it doesn't require me modifying my object at all.
Thanks!
-David
----- Original Message ----- 
From: "Barett McGavock" <bm...@pulvertech.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Cc: "'David Erickson'"
<IM...@pulvertech.com>
Sent: Wednesday, December 17, 2003 5:18 PM
Subject: RE: Best way to parse a String and replace line feeds with <br> for
html?


> Thoughts:
> 1) Assuming that you have a separate value object to carry this
> item to the view, try replacing any "\n" with "<br>" in the action.
> 2) Have you also considered using the <pre> HTML tag?
>
> B
>
> -----Original Message-----
> From: David Erickson [mailto:derickson@cmcflex.com]
> Sent: Wednesday, December 17, 2003 5:05 PM
> To: Struts Mailing List
> Subject: Best way to parse a String and replace line feeds with <br> for
> html?
>
>
> Situation:
> using the html:textarea element tag to enter notes on an object, thats
> getting persisted as a blob in our database.  I would like to be able to
> output this to html with the same formatting.. ie the line feeds work.
Whats
> the best way to do this?  I tried the jstl:core c:out tag and it didnt
work
> (did not goto the next line), tried the struts bean:write tag same
problem.
> Is there another struts tag library I can use? Thanks, David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Best way to parse a String and replace line feeds with
f or html?

Posted by Jason Lea <ja...@kumachan.net.nz>.
That does mean you are adding some html formatting to the action which 
isn't so nice.  Another option that I have used while waiting for the 
next version of JSTL is the jakarta string taglib:  
http://jakarta.apache.org/taglibs/doc/string-doc/intro.html

eg

|<str:replace replace="NL" with="&lt;br&gt;NL" newlineToken="NL">
A sentence.
Another sentence.
Some more to test. And insert Br's into.
Hopefully.</str:replace>|

So you can leave the object/form as is, and use this taglib to change 
newlines to <br>'s on the JSP page


Barett McGavock wrote:

>Thoughts:
>1) Assuming that you have a separate value object to carry this 
>item to the view, try replacing any "\n" with "<br>" in the action.
>2) Have you also considered using the <pre> HTML tag?
>
>B
>
>-----Original Message-----
>From: David Erickson [mailto:derickson@cmcflex.com] 
>Sent: Wednesday, December 17, 2003 5:05 PM
>To: Struts Mailing List
>Subject: Best way to parse a String and replace line feeds with <br> for
>html?
>
>
>Situation:
>using the html:textarea element tag to enter notes on an object, thats
>getting persisted as a blob in our database.  I would like to be able to
>output this to html with the same formatting.. ie the line feeds work. Whats
>the best way to do this?  I tried the jstl:core c:out tag and it didnt work
>(did not goto the next line), tried the struts bean:write tag same problem.
>Is there another struts tag library I can use? Thanks, David
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>  
>


-- 
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org