aspose file tools*
The moose likes Servlets and the fly likes When has the hashtable been populated? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "When has the hashtable been populated?" Watch "When has the hashtable been populated?" New topic
Author

When has the hashtable been populated?

Kaiser Lautern
Greenhorn

Joined: May 11, 2005
Posts: 18
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
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
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.
Kaiser Lautern
Greenhorn

Joined: May 11, 2005
Posts: 18
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
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, that line sets up the rule.
Nothing happens until you call the parse method.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When has the hashtable been populated?
 
Similar Threads
Database servlet
fileREader and FileWriter
data type
Uploading an Image
Digester Problem