Please see it

I mad a textarea in an html file and got the input to insert into db. the record was as follow:

I am going to send you following books:

1). Java

2.) Servlets

but when I displayed it showing like following:

I am going to send you following books:1). Java2.) Servlets

how can I show it correctly.

thanks and kind regards

[368 byte] By [farakha] at [2007-11-26 21:59:47]
# 1
Some code would help..
despinaa at 2007-7-10 3:59:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Inserting record is ok but when am using this code:

rs=stm.executeQuery("select bb from tableName");

if(rs.next()){

out.println(rs.getString("bb"));

}

The inserted record is:

I am going to send you following books:

1). Java

2.) Servlets

output of the above code is:

I am going to send you following books:1). Java 2.) Servlets

farakha at 2007-7-10 3:59:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
try to insert this insetad:"I am going to send you following books:\r\n1). Java\r\n2.) Servlets\r\n"
java_2006a at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

[nobr]rs=stm.executeQuery("select bb from tableName");

if(rs.next()){

out.println(rs.getString("bb")+"<br/>");

}

or

<ul>

rs=stm.executeQuery("select bb from tableName");

while(rs.next()){

<li>out.println(rs.getString("bb"));</li>

}

</ul>

[/nobr]

despinaa at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Despinayour both of the codes are not working. please check it by yourself.thanks
farakha at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

what's the object out in your code ?

try this:

rs=stm.executeQuery("select bb from tableName");

if(rs.next()){

out.println(rs.getString("bb")+"\r\n");

}

java_2006a at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

Hi

I tried this code both in IExplorer and FireFox and it is working fine.

<body>

<%

for( int i=0;i<5; i++){

out.println("Printed"+"<br>");

}

%>

</body>

So u try this

out.println("I am going to send you following books:"+"

");

out.println("1). Java"+"

");

out.println("2.) Servlets"+"

");

This should work.

Thanks.

invincibleBoona at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

Java_2006 and invincibleBoon:

Actually my right problem is that I am getting input from textarea as I said in my first post.

So i don't know what the input will be sended by the end-user but one thing is clear that I am unable to print the output as it is given by the user. When I tested it. its just printing the data from db in one line.

kind regards

farakha at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9
If you are getting multi-line info from a db (or where ever) and you need to display it in HTML, then you need to replace the end of line characters (whether that be \r for MAC, \r\n for PC, or \n for *nix, so check for all three) with "".
masijade.a at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

> If you are getting multi-line info from a db (or

> where ever) and you need to display it in HTML, then

> you need to replace the end of line characters

> (whether that be \r for MAC, \r\n for PC, or \n for

> *nix, so check for all three) with "

".

e.g. there is a paragraph in db and am displaying. So the question is how my servlet code will knows that this is the end of line or paragraph?

farakha at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11
regex
masijade.a at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 12
> regexPlease be more specificthanks & kind regards
farakha at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 13

Well, how do differentiate between a normal newline and a paragraph in the data? If you don't differentiate between the two in the data itself, then how the hell do you want to differentiate between the two when you are reading and displaying the data?

Do you have extra indentation on the first line of a paragraph?

Do you have an extra newline (a blank line) before the start of a paragraph?

You might be able to swing something by checking for a line shorter than a specific length, and then assumming that the next line is the start of a paragraph which should catch at least some instances of a new paragraph, but it is far from perfect.

In otherwords, store the data using some marker for the start of a paragraph, either one of the two mentioned above or maybe some symbol of your own like ===== that you can then leave out of the displayed text, or you cannot differentiate (at least not reliably).

masijade.a at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 14

> Well, how do differentiate between a normal newline

> and a paragraph in the data? If you don't

> differentiate between the two in the data itself,

> then how the hell do you want to differentiate

> between the two when you are reading and displaying

> the data?

>

> Do you have extra indentation on the first line of a

> paragraph?

>

> Do you have an extra newline (a blank line) before

> the start of a paragraph?

>

> You might be able to swing something by checking for

> a line shorter than a specific length, and then

> assumming that the next line is the start of a

> paragraph which should catch at least some instances

> of a new paragraph, but it is far from perfect.

>

> In otherwords, store the data using some marker for

> the start of a paragraph, either one of the two

> mentioned above or maybe some symbol of your own like

> ===== that you can then leave out of the displayed

> text, or you cannot differentiate (at least not

> reliably).

I am really afraid to ask this but please don't mind it. can you get me an example with just little code clue

thanks & regards

farakha at 2007-7-10 3:59:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...