Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

custom tags threadsafety

144 views
Skip to first unread message

Geordie

unread,
May 9, 2001, 11:38:37 AM5/9/01
to

I'm confused as to the thread safety requirements of custom tags. Since tags are
compiled into Servlets and run as servlets do they not need to be coded with threadsafety
in mind? I was browsing some examples recently (not the wls) and it seems they
were not written in this manner.

Thanks,
Geordie

Cameron Purdy

unread,
May 9, 2001, 11:00:18 AM5/9/01
to
> I'm confused as to the thread safety requirements of custom tags. Since
tags are
> compiled into Servlets and run as servlets do they not need to be coded
with threadsafety
> in mind?

Tags are not compiled into Servlets.

Unless you do something fancy within your tag, the tag will only be used on
a single thread, that which is processing the containing JSP.

JSPs are compiled into Servlets. The JSP 1.1 spec contains discussion on
thread safety issues, and the page attribute provides the means to declare a
single-thread model, just as with Servlets.

Peace,

--
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available


"Geordie" <geordie...@hotmail.com> wrote in message
news:3af9566d$1...@newsgroups.bea.com...

Mike Reiche

unread,
May 9, 2001, 1:23:21 PM5/9/01
to

Tags are not exactly 'compiled into servlets'.

JSPs with tags are compiled into servlets which - create
instances of the tags and use them. Thus an instance of
a tag is not used in two requests. (use keepgenerated when
you compile your jsps and check out the resulting java files)

However, if tags use the httpSession or the PipelineSession,
then you have threading issues as there is only one httpSession
for multiple requests (from the same browser).

Mike

Benjamin Menasha

unread,
May 9, 2001, 11:27:31 AM5/9/01
to
Just to clarify twhat Mike said, the same Tag object is never called by multiple threads at
the same time. The whole Tag interface is very "statefull", often containers
will pool a collection of tags and pull from the pool as needed. The lifecycle
of a tag is much simpler then for servlets or ejbs, so often these pools are
easy to manage and fast. The threading issues that Mike is talking about occur
because two request might be running in the same session because the user has two
browser windows open, and is using both. This case unfortunatly is often
overlooked.

-b

0 new messages