Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Load MySQL text into JSP textarea  RSS feed

 
Ranch Hand
Posts: 85
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: 67239
170
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: 3921
45
  • 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: 85
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: 3921
45
  • 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: 85
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: 3921
45
  • 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: 85
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: 3921
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then only display a value if historico is not null.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!