Lock taglib ver. 1.3

    Custom JSP tag. Lets you synchronize (serialize) execution for tag's body. Tag's attribute describes some semaphore. You may have of course more than one semaphore for your application.

For example, this code implements some counter on the application level. Access to this counter (increment) will be serialized:
 


<%@ taglib uri="taglib.tld" prefix="set" %>

<set:lock semaphore="A">
  <%
   Integer v=(Integer)pageContext.getAttribute("counter", pageContext.APPLICATION_SCOPE);
   if (v==null) v=new Integer(0);
   pageContext.setAttribute("counter", new Integer(v.intValue()+1), pageContext.APPLICATION_SCOPE);
  %>
</set:lock>

counter is <%=(Integer)pageContext.getAttribute("counter", pageContext.APPLICATION_SCOPE)%>

So this tag lets you organize access to shared data.

.NET users may conclude that this tag extends application.lock and application.unlock operators in ASP.NET.

Tags are:

lock

Body tag. Executes own body in the synchronized mode. Parameters are:

1) semaphore name for semaphore
2) cond Optional attribute. Describes a boolean value tag's behavior depends on. Default value is true (use synchronized mode).

for downloading:

Library: locktag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: