0

How to keep the symbol of a new paragraph "\n" in jsp page? Text data comes from the database. Text in database contains new paragraph. But jsp page does not preserv new paragraph in text. Jsp uses c:out tag for output. What are the options to resolve this?

andy007
  • 907
  • 1
  • 15
  • 41
  • So do you want to replace new line character or want to keep it? – Braj Jun 14 '14 at 19:03
  • It might help you. Read [How can I replace newline characters using JSP and JSTL?](http://stackoverflow.com/questions/58054/how-can-i-replace-newline-characters-using-jsp-and-jstl) – Braj Jun 14 '14 at 19:19
  • 1
    Braj, I wanted to keep new line character and that link really helped me. Thks. – andy007 Jun 14 '14 at 20:56

1 Answers1

0

JSP sends the text string directly to the browser of the client. its up to the client browser to interpret the data received. Therefor the data sent from jsp is still treated as HTML. even though \n character is sent to the browser, the browser will not create a new paragraph! to create a new paragraph, the browser needs <br/> or other block level element like <p> and <div>. Or if you want the string to be displayed as it is insert it in a <pre> tag. that will tell the browser to print the incoming string as it is. I hop i got the question right!

Amanuel Nega
  • 1,899
  • 1
  • 24
  • 42