tags:

views:

65

answers:

1

Hi, could anyone please clarify the meaning of line generalizes the tag object's storage of attributes in the following line of Head First Servlets & JSP (page no. 555):

One solution would be to put all of the attributes into a hashtable. This generalizes the tag object's storage of attributes, but what about all these setter methods? We can't get rid of them unless there's a way to tell the JSP engine to set the tag attributes using a generic interface.

Thanks in advance.

+1  A: 

"Generalizes" in this context means that you can write one function or one small piece of code that implements all of your cases rather than writing each case separately. I don't have that book, but it looks like it replaces something like:

 String attr1;
 String attr2;
 String attr3;

with

 Hashtable<String, String> attributes;

That's generalizing the storage -- the code is meant to show a generic hashtable that maps strings to strings -- you would use something like this

 attributes["attr1"] = "value";

The other code would be used something like this:

 attr1 = "value";
Lou Franco