-1

Consider the case below..this article has multi paragraphs.how to i retrieve it on a html page with loosing the breaks between each paragraphs

Keeping the issue of prime ministerial candidate on the back-burner, 11 Left and secular parties on
Tuesday came together claiming to be the alternative and vowed to defeat both Congress and BJP.

The announcement was made after an hour-long meeting here of the leaders of JD(U), Samajwadi Party,
AIADMK, JD(S), Jharkhand Vikas Morcha and four Left parties.

The 11-party combination also came out with a joint declaration which said “it is time for a change
and to throw out the Congress from power... The BJP and the communal forces must be defeated and
prevented from coming to power.”

Accusing the Congress of have “a record of misrule, massive corruption, unprecedented price rise and
creating glaring inequalities”, CPI(M) General Secretary Prakash Karat said “we will work for the
defeat of the Congress.”
ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
lehrer
  • 37
  • 1
  • 1
  • 3
  • You can generate HTML and put it to the database – Maxim Feb 25 '14 at 13:30
  • 1
    Please clarify your question -- are you asking how to retrieve "html" and remove paragraph breaks; or something else? – ErstwhileIII Feb 25 '14 at 13:30
  • while a user creates a new article he/or she adds it in a textarea... this text area has multiple paragraphs..consider you are typing an email gmail with multiple paragraphs..the formatting is not lost.. i want the same kind of logic when a user reads the article after retrieving from db..not like a single string – lehrer Feb 25 '14 at 13:33

2 Answers2

0

If you're displaying as HTML, why not store the paragraph in the document?

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
Thom
  • 14,013
  • 25
  • 105
  • 185
  • i want to create a an app which has a number of articles stores in a db .the articles are written by the users. so i need to store it in db – lehrer Feb 25 '14 at 13:29
0

Write a function before storing the data to replace the line breaks with <br\> tags. This will help the browser to render it in the same way !

You can follow the following links for better idea

replace \n and \r\n with <br /> in java

Replacing all consecutive "\r\n or \n"s with one single <br>

Community
  • 1
  • 1
ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176