• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When has the hashtable been populated?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to understand the servlet code below, which is supposed to read the data from an xml file and load it to a hashtable. However, I couldn't figure out exactly at what time has the hashtable been populated.



I don't know the Digester API, but it seems that all it does is to populate the User and Subscription DTO's. Next, in the servlet's init() method (where load() is called) it's assumed that the hashtable is already populated:



Thanks,


Kaiser
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a line that says digster.push(this). The gives the digester a reference to the instance of the class that is calling digester. So either, digster uses and accessor method(s) to manipulate the database object, ie getDatabase(), or addItemToDataBase(..) or database is a public variable in the class? (that is something you can check).

Either way, the actual answer to your question is almost certainly, on this line:
digester.parse(bis);
[ May 15, 2005: Message edited by: Tim Baker ]
 
Kaiser Lautern
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks fr your answer Tim. I went and checked the Digester API. In fact the answer is in the line:


It calls the method addUser on the parent element (position top-1 in the stack and in this case, the servlet itself). And the addUser method in the servlet does the actual job:



Kaiser
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, that line sets up the rule.
Nothing happens until you call the parse method.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic