my dog learned polymorphism*
The moose likes JDBC and the fly likes Retrieving formatted text from mysql database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieving formatted text from mysql database" Watch "Retrieving formatted text from mysql database" New topic
Author

Retrieving formatted text from mysql database

Shashank Anand
Greenhorn

Joined: Oct 30, 2008
Posts: 26
Hi,

I have a column of datatype 'text' in mysql table. I insert text using a textarea in a jsp page, like:

Hi this is Shashank.
Glad to meet you.

Bye.

When I retrieve the data, it comes out like 'Hi this is Shashank. Glad to meet you. Bye.' in a single line. Will anybody please guide me how I can maintain the text format that was put into the database and display it in the same format?

Thanks in advance.
Shashank


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Shashank,
There are two places where the formatting could be getting lost:

1) Between submitting it and storing it in the database
2) Between retrieving it and painting the page

Do you know which of the two is causing the problem. In any case, this is likely to be an HTML question rather than a database one so I'll move it to our HTML forum.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

All you said was "it comes out like...". You didn't say "When I displayed it in a text area it looked like..." so I'm guessing you didn't display it in a text area. So it would be useful to know what tool you WERE using when you displayed it.
Shashank Anand
Greenhorn

Joined: Oct 30, 2008
Posts: 26
You are right.

So far I was trying to display the records from database in a html table. Now I retrieved it in a text area, the format was perfect. So that means the formatted text itself is saved in the database. Do you have any idea if the display is not in a text area, but simply in a paragraph like how to get the formatted text?

Regards,
Shashank
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieving formatted text from mysql database