• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Load MySQL text into JSP textarea

 
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I'm to trying  to  load an mysql text collumn to my jsp textarea by my servlet application, the problem is that my textarea are receiving the content of my bean used in my DAO List plus last record of my MySQL table.
This is my textarea tag:

This is my method to get the text of MySQL tabel:

And this is the content load in my jsp textarea:


Look,  this is only one text write in my MySQL table to test, I have three records in my table and this is the last record in my table. But the two first records are don't load.

Is there anyone to help me?

Thanks a lot.

Cezar apulchro.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the code for pcdaohist.getHistoryPaciente(). That's where the value is coming from.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, what is being logged from that println call on line 14?
I assume it's the same as you see in the page.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear, Dave.
here is my pcdao.getHistoryPaciente:


Dave this is resulst of println line 14:


Thanks in advance.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK.
What should it be displaying?

I'm guessing that the rest of those fields are coming from the DadosPaciente class?
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Dave, are you right. The question is why?
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because this:

is telling the JSP to print out the contents of historico (using its toString()).

And historico comes from histConsulta, which comes from the output of getHistoryPaciente(), which is a List<DadosPaciente>.

So the toString is the one from the List, which cycles over the contents of the List (which are instances of DadosPaciente) and calls their toString methods.
I'm guessing that the toString for DadosPaciente produces a String that contains all the attributes of DadosPaciente.  Since only History_Paciente is populated, all the rest are null.

So, if you only need the one attribute then I would suggest just making that a List<String>, after all the method is called getHistoryPaciente and not getDadosPaciente.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very good Dave,
this is my DAO:

this is my method:

Dave, when line 14 of my method is executed the first item of my jsp textarea is null because historico is null first time. Can you tell me how I solve this problem?

Thanks in advance.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then only display a value if historico is not null.
reply
    Bookmark Topic Watch Topic
  • New Topic