This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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:
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 ]
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Joined: May 11, 2005
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: