How to print Java Bean completely using reflection or any other utility

Viewed 23210

I have an Java bean class Person containing 3 variables:

  • name (String)
  • age (String)
  • address (Object).

Address contains 3 variables:

  • street
  • door_no
  • city

I would like to have a utility which should print all variables in Person.

By this I mean it should print Person & also the Address object contained in it.

I could create a hashmap and put the variable names & values using reflection and print key/value UI in JSP but the issue is I have to apply reflection for Address to add variable/value in the hashmap.

Is there a utility available to do this?

4 Answers
Related