aspose file tools*
The moose likes Servlets and the fly likes Displaying half sting only from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Displaying half sting only from database" Watch "Displaying half sting only from database" New topic
Author

Displaying half sting only from database

Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100



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
Marshal

Joined: Mar 22, 2005
Posts: 42922
    
  68
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
Ranch Hand

Joined: Aug 27, 2012
Posts: 1110
    
  10

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

Joined: May 09, 2012
Posts: 100

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

Joined: May 09, 2012
Posts: 100

Thank you Richard ..now its working as required.
"Slow again !"???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100

I agree.
Very soon i'll learn JSP.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying half sting only from database