how to preserve text formatting in java

i am creating a blog which have different topics and user can give their comments.
i am stuck at one point, when user posts its comment, it will not in the format
what the user write in the textarea.

for e.g

this is a nice topic

coming as:

Hi this is a nice topic Thanks

i want that comment post would be in same format as its posted
i think i have to write a java class for formatting but i dont have an idea of it

can any one suggest me waht to do.

Thanks in advance