Is there any reason you don't want to just do this?:
<pre>
<% for (i =0; i < log_message.size(); i ++) { %>
<p> Message: <%out.println(log_message.get(i).toString());%>
<% } %>
</pre>
ie. just leave the \n in the text but tell the browser that it is preformatted.
-----Original Message-----
From: hugo [mailto:hugo@;GEOINFORMEX.COM]
Sent: Monday, October 28, 2002 2:50 AM
To: [EMAIL PROTECTED]
Subject: convert \n to <p> in jsp print statement
Hi
I have text which I submit to and retrieve from a database. When I
submit to the database, it seems that the line breaks are preserved, but
when I want to retrieve the text to my browser, everything becomes one
long on-going stream of text. Presumably the \n line breaks exist in the
database but they have to be converted to <p> tags for the browser to
display them as line breaks.
I am using a jsp which has a vector called log_messages to obtain the
messages from the database. After obtaining them, I then display these
messages with the following code.
<% for (i =0; i < log_message.size(); i ++) { %>
<p> Message: <%out.println(log_message.get(i).toString());%>
<% } %>
But I would like to convert the newline characters \n (which presumably
are there in some of the message bodies) to <p> statements so new
paragraphs will be showing. Is there an easy way to do this?
Any help will be greatly appreciated.
Thanks
Hugo
--
Dr Hugo Bouckaert
Systems and Programming Engineer
GeoInformatics Exploration Australia P/L
57 Havelock St
West Perth, WA 6005
PO Box 1675, West Perth 6872
Ph: 61 08 9420 7400
Fax: 61 08 9226 1299
www.geoinformex.com
------------------------------------------------------------------------
This email and any attachments may be confidential or legally
privileged. If you received this message in error or are not the
intended recipient, you should destroy the e-mail message and any
attachments or copies, and you are prohibited from retaining,
distributing, disclosing or using any information contained herein.
Please inform us of the erroneous delivery by return e-mail. Thank you
for your cooperation.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
DISCLAIMER:
The information contained in this e-mail may be confidential and is intended solely
for the use of the named addressee. Access, copying or re-use of the e-mail or any
information contained therein by any other person is not authorized. If you are not
the intended recipient please notify us immediately by returning the e-mail to the
originator.
==========================================================================To
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com