Thanks for your answer. Sorry but I do not get what is exactly want suggested here.
Could you please correct the code snippet posted.
Main Topics
Browse All TopicsHallo Experts,
I have a text stored in database which I need to display in the textarea.
Text stored in db is like below.
some text \n second line \n bla bla
Now if I want to display it in the text area in my JSP page it gets displayed with \n in the text. How can I display the line break in place of the \n. I tried replacing it with br. Please see html code below.
Can somebody help
TIA
Regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
That's too bad. iBatis makes some things easier, but as soon as you have to step outside the box, it's hard to fix.
Can you post what the data looks like in the database? Then I can determine if iBatis is causing the problem.
The problem is that the HTML you showed above is not normal for a string with line breaks in it.
If, indeed, the string is as you said, then you can change the "\n" sequence to a real line break something like this:
<%
String origText = bean.getText();
String goodText = origText.replaceAll("\\\\n
%>
Then in your JSP page, put something like:
<textarea class="disable" disabled><%=goodText%></textar
By the way, the JSP you posted does not match the HTML you posted. Are you sure you're dealing with the right code?
rrz@871311: If you look at the posted HTML and JSP, inditrozen already has examples of various strings being displayed in the textarea.
The question is how did a valid newline (assuming that there was an original valid newline) turn into the string "\n" in the database.
And if inditrozen cannot show the code for that from iBatis for us to fix, then what workaround can he do to change the "\n" string in the value from the database into an actual newline on the HTML page. Which is the code I posted above.
Hi mrcoffee, I am sorry if I have misunderstood inditrozen's question.
But in the question he posted
>Text stored in db is like below.
>some text \n second line \n bla bla
So, I think the newlines are there in the db text. He just needs to use java to read them. That is why I posted my code to demonstrate that.
mrcoffee>into an actual newline on the HTML page
no, inditrozen posted
>I have a text stored in database which I need to display in the textarea.
Please run my demo code and look at the source code in browser.
He posted what the bean.text displays in his original question. If there were newlines in the code from the db, then there would not be "\n" text in the output in the HTML page.
Or, iBatis reads the text from the db, and automatically converts the actual newlines into "\n" strings. I don't know what iBatis does, but an output string with "\n" in it is clearly wrong at some point.
Business Accounts
Answer for Membership
by: mrcoffee365Posted on 2009-01-13 at 09:54:20ID: 23365298
You have to actually put the newlines in the string that prints from your JSP, not escaped \\n, which it looks like you must have done.
Notice in the above example, if you replace the "\n" with actual newlines in a text editor, and display the page, then the textarea has the newlines.
The <br/> tag is not recognized within textarea, so that's not a good solution. It's the right thing to do, however, when you want to display the text when it is not in the input textarea. In that case, you would want to convert all of your newlines in the db field into <br/> -- it looks as if you only converted some of them in the example you posted.