• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Load MySQL text into JSP textarea  RSS feed

 
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • 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.
 
Marshal
Posts: 67197
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the code for pcdaohist.getHistoryPaciente(). That's where the value is coming from.
 
Rancher
Posts: 3798
40
  • Mark post as helpful
  • send pies
  • 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: 65
1
  • Mark post as helpful
  • send pies
  • 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: 3798
40
  • Mark post as helpful
  • send pies
  • 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: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Dave, are you right. The question is why?
 
Dave Tolls
Rancher
Posts: 3798
40
  • Mark post as helpful
  • send pies
  • 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: 65
1
  • Mark post as helpful
  • send pies
  • 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: 3798
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then only display a value if historico is not null.
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!