Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying half sting only from database

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the code with which i am retrieving records and displaying it on page.
At first occuring of value[0] its showing ,line 29, "Anisha Singh"(inserted in databse)
but at second place, incide textbox its showing only, line 45 , "Anisha".
Its not showing complete string stored.
Please help me to solve it.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because the code generates bad HTML. Attribute values need to be enclosed by quotes, other wise you'll run into trouble if they contain special characters or spaces (as in your example). If you take a look at the generated HTML you will see that the output is exactly what it should be according to the Java code - it's just not proper HTML, and thus does not behave in the browser like you expected it to.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is your informal use of HTML. Attribute values should be enclosed in quotes so your line
is not strictly valid syntax and should be

Note the extra quotes.

:-) Slow again !
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know JSP .. so the option i left with to generate HTML code within the servlet.
It will really very help if you can guide me to right direction.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Richard ..now its working as required.
"Slow again !"???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Singh Anisha wrote:
"Slow again !"???

He means that Ulf beat him to the punch.

You should be learning JSP. Building up HTML in strings in a servlet is a horrible way to do things.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree.
Very soon i'll learn JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure that you learn modern JSP. If you see Java code in a JSP, that's old technology that's been obsolete for 11 years. Be sure to learn JSP with the JSTL and EL.

You might also want to read this article to help get started.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic