• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Populate JavaBean With Data Fetched From the Database

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic