Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Populate JavaBean With Data Fetched From the Database

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bean. There are three field variables in the bean; username, userrole, and category. "username" is supplied by me. "userrole" and "category" in the bean gets populated by fetching data from the database. I am positive that data are present in the database. However, I got "blanks" when I later on tried to display the properties (userrole and category) of that bean. I would appreciate if anybody could help identifying the problem. The relevant codes are show below:

My data access code is show below:

[ November 28, 2003: Message edited by: JiaPei Jen ]
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything wrong with your code (quick look though). What I recommend is to print to the log the values you get from the DB

doing that you ensure that you're getting something from the DB, and not empty or null.
hope it helps
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data table is created by me. I am positive that every field in the table has a value for every single record.
In my JSP, I am able to display the value of "username". It means that the session object can be found. The JSP does not display anything (it is blank) for "userrole" and "category".
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check to see whether the fieldnames of your jsp page are one and the same as in the properties of the java bean.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. I would check and verify that your jsp/property attributeS are in synch with your get/set methods of your bean.
For example, I noticed that that the following methods are different. Because the
getc[atagory is not the same as the setCategory:

Check that with your jsp page.
Craig
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic