0

Here is my data when i view in SQL Developer tool

introduction
topic 1

topic end

and after i read it using a ResultSet,

ResultSet result = stmt.executeQuery();
result.getString("description")

and display in JSP page as

<bean:write name="data" property="description" />

but it will display like this

 introduction topic 1 topic end

how can i keep the display same as in the SQL Developer?

ggDeGreat
  • 1,098
  • 1
  • 17
  • 33

2 Answers2

1

how can i keep the display same as in the SQL Developer?

The data presumably contains line breaks, e.g. "\r\n" or "\n". If you look at the source of your JSP, you'll probably see them there. However, HTML doesn't treat those as line breaks for display purposes - you'll need to either use the <br /> tag, or put each line in a separate paragraph, or something similar.

Basically, I don't think this is a database problem at all - I think it's an HTML problem. You can experiment with a static HTML file which you edit locally and display in your browser. Once you know the HTML you want to generate, then work on integrating it into your JSP.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

Newlines aren't preserved in HTML. You need to either tell the browser it's preformatted:

<pre>
    <bean:write name="data" property="description"/>
</pre>

Or replace the newlines with HTML line breaks. See this question for examples.

Community
  • 1
  • 1
David Grant
  • 13,929
  • 3
  • 57
  • 63