Variable concatation

hey all,

I am fetching a data from SQL DB and displaying into the textboxes in Servlets. But for name, only First name is coming up and Last name itself is getting trunketed. i.e. instead of Amitabh Bachchan in testbox it is coming Amitabh only and Bachchan getting cut off.

I am using folowing expression :

out.println("<td><input type=text name=\"empl_name\" align=\"left\" size = \"30\" value="+ e_nm_db +">"+e_nm_db+"</td>");

here e_nm_db inside the input command giving only First name but outside that is giving Full name perfectly.

Can any1 help me regarding this?

thax & rgds,

nhb007

[662 byte] By [nhb007a] at [2007-10-3 9:19:38]
# 1
put quotes around your html attributes...i'm not joking : ALWAYS put quotes
alban.maillerea at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thax for replying, but I`ve already put quotes for all HTML attributes...where u cldn`t find?thax & rgds,nhb007
nhb007a at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
"value="+ e_nm_db +">"that gives you value=Amitabh Bachchan>what will result in "Amitabh" being the value, "Bachchan" being ignored and your html being awfulDid you simply look at the generated HTML before posting?
alban.maillerea at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
hey alban.maillere,I didn`t get wt u meant to say...Currently my value is "Amitabh Bachchan" then why and how it is cutting it off? can u tell me directly that only?thax & rgds,nhb007
nhb007a at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

because without quotes around attributes, the space is considered as the end marker of the value

seriously : in your code juste put System. before your code

System.out.println("<td><input type=text name=\"empl_name\" align=\"left\" size = \"30\" value="+ e_nm_db +">"+e_nm_db+"</td>");

on the console you'll see

<td><input type=text name="empl_name" align="left" size = "30" value=Amitabh Bachchan>Amitabh Bachchan</td>

and that is WRONG html

alban.maillerea at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hey alban,

U r right, that in System it is showing perfectly fine, but here outside input tag I`ve put, is just to have idea that what actually is Data and inside input is what it prints.

So can u temme how to avoid this? I know I might b irritating but I m new to this so have lots of Qs and queries...:)

thax & rgds,

nhb007

nhb007a at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
As i said just put quotes, like that :out.println("<td><input type=text name=\"empl_name\" align=\"left\" size = \"30\" value=\""+ e_nm_db +"\">"+e_nm_db+"</td>");
alban.maillerea at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
hey alban.maillere,Geneius man...Hurray!!!! thax buddy, it worked perfectly.thax & rgds,nhb007
nhb007a at 2007-7-15 4:32:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...