Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

newline character JSP JavaScript

843836Dec 6 2003 — edited Dec 9 2003
I encountered a problem in my attempt to integrate an open source JavaScript rich text editor with a lite CMS program work on. The program is based on the JSP technology and has a servlet centric architecture.
the problem in a nutshell is this.

somefile.jsp:

<td colspan="3">
<script language="JavaScript" type="text/javascript">
var a = "<%= paragraph.getText() %>".replace("\n", "<BR>");
writeRichText('rte1', a, 560, 200, true);
</script>
</td>

the open source rich text editor accepts among others a parameter to intantiate a rich text editor-able textarea with some data. (perfect for editing some text).

The problem arises when i try to instantiate this text editor with writeRichText() because of my requirement to get a paragraph as data entry. My paragraph javaBean object returns a String object when getText() is called. This cause browsers to formulate this error message:

Error:
unterminated string literal
Source File: http://localhost:8080/***
Line: 74, Column: 8
Source Code:
var a = "<P>sometext</P><P>newline hereafter->

clearly its about the first newline charater that composes one of my paragraphs.

the question:

Is it possible to change all the newline characters in my paragraph object to <BR> (HTML breakline tag) before sending it to the rich text editor function? how do i do that? any code examples are very wellcome.

regards

The used text editor is developed by Kevin Roth and can be found at:
http://www.kevinroth.com/rte/demo.htm
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 6 2004
Added on Dec 6 2003
4 comments
705 views