How to identify existing linebreaks in a column of type 'text' in postgresql database to display them on a html/jsp page?

JMS :

I could not find a similar question asked, despite being sure that somebody else has to have run into a similar problem before. I could only find the other way around, how to insert but not how to read. Any pointer to a similar question would be appreciated.

I have a PostgreSQL database with a column of type='text' which contains multiple linebreaks.

Snapshot of a database entry.

I am looking for a way to display these linebreaks on my .jsp page currently using mainly Expression Language (EL) (could also switch to CustomTags if there is a feasible way). Currently, whenever I query this particular field in the database, I save the contents in a own data type (as String variable), put the datatype into the session and call it using EL. However, then the linebreaks are lost and the text will only be appended.

It works, if i manually put a HTML linebreak into the entries inside the database. However, there are over 1000 entries, so manually manipulating the data does not seem to be a feasible option.

Is there a way to identify the linebreaks as seen in the picture?

devNNP :

Browser doesn't use \n to break lines, only <br>. So when you print data with \n linebreaks browser doesn't understand it. You can try to add HTML linebreaks to show your data in multiple lines in your jsp-page. For example: you can split your data to array with \n and print it, every time adding <br>.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=357248&siteId=1