Meaningless Drivel is fun!
The moose likes JSP and the fly likes Taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Taglib" Watch "Taglib" New topic


Prad Rayan

Joined: Nov 18, 2001
Posts: 7
Hi ,
I have a JSP page where I have 10 occurences of the same custom tag
<test:service entity="31asd"/> where the value of the attribute 'entity' is different at all the 10 places , I would like to know if I can use one instance of the bean to handle all the 10 values .
I am looking at some behaviour similar to the <jsp:useBean> where it is possible to scope an object .
Please let me know if there is a feature that supports my requirement.
Note : I am using JSP 1.1 compliant Server .
ted oniger

Joined: Aug 05, 2001
Posts: 16
Hi Prad,
I am not really sure if this is a direct answer to your question. A servlet engine may maintain a pool of tag instances, so if there's an avaialable instance of your tag (even if its attributes change) the engine will use that instance. However we (as programmers) have no control over the pooling that takes place.
Regarding your question if you can use a single instance of your tag to handle the same tag ten times with different values of its attribute, I think the engine uses just one instance. This also answers the threading issues, because an instance cannot be used until it's free. I got all these ideas from the book "Java Server Programming, J2EE Edition"
Hope this helps.
Prad Rayan

Joined: Nov 18, 2001
Posts: 7
Thanks for your reply , the fact that the Servlet Engine maintains a pool of tags is something I haven't come across.
But when I ty to print the "free memory" before and after the operation in the JSP . I create 50 custom tags , each of which executes a service . When the custom tag approach was used it resulted in a usage of close to 100,000 bytes , on the contrary when the <jsp:useBean> was used as a replacement , it resulted in only 8000 bytes being consumed .
I have a feeling that my Servlet Engine , attempts to create a new object for every custom tag.
Is there any way to prevent the container from instantiating a bean for every custom tag ?
I agree. Here's the link:
subject: Taglib
It's not a secret anymore!