Load balance taglib ver. 1.4

    Custom JSP taglib. This taglib lets you change in dynamic links for resources on your HTML pages. Suppose you have a site with heavy traffic. In order to unload your server you may decide to serve some requests from other boxes in your cluster. For example in your HTML page you can use this taglib for images:
 


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

<lb:img src="pic.gif" param="A" />

Here A describes a context parameter for your web application. Tag assumes that this parameter describes a list of available servers (comma separated). E.g. in your web.xml file you can have some like this:
 


<context-param>
<param-name>A</param-name>
<param-value>http://www1.host.com, http://www2.host.com</param-value>
</context-param>

and it this case tag img will use as a source http://www1.host.com/pic.gif or http://www2.host.com/pic.gif.

If context parameter A does not exist than tag will use src parameter "as is".

In other words this tag provides a load balance schema for your resources. This taglib supports load balanced equivalents for three HTML tags: img, href and form (you can rotate URL's for action parameter.)

Tags are:

img

Provides a load balanced replacement for HTML img tag. Parameters are:

1) src Describes source for image
2) param Optional parameter. Describes a context parameter with the list of rotated URL's.
3) border Optional parameter. Describes a border for image
4) width Optional parameter. Describes a width for image.
5) height Optional parameter. Describes a height for image.
6) encode Optional parameter. Possible values are true or false. If this value is true than URL for scr will be encoded. Default value is false.
7) className Optional parameter. Describes a CSS class.
8) style Optional parameter. Describes a CSS style.
9) alt Optional parameter. Describes an alternate text for your image.

link

Body tag. Provides a load balanced replacement for HTML <a href tag. Tag's body defines a link. Parameters are:

1) href Describes a href parameter
2) param Optional parameter. Describes a context parameter with the list of rotated URL's.
3) target Optional parameter. Describes a target frame
4) title Optional parameter. Describes a title (tooltip)
5) rel Optional parameter. Describes a rel attribute
5) encode Optional parameter. Possible values are true or false. If this value is true than URL for href will be encoded. Default value is false.
6) className Optional parameter. Describes a CSS class.
7) style Optional parameter. Describes a CSS style.

form

Body tag. Provides a load balanced replacement for HTML form tag. Parameters are:

1) action Describes an action parameter
2) param Optional parameter. Describes a context parameter with the list of rotated URL's.
3) target Optional parameter. Describes a target frame
4) name Optional parameter. Describes a name for your form
5) encode Optional parameter. Possible values are true or false. If this value is true than URL for action will be encoded. Default value is false.
6) onsubmit Optional parameter. Describes an onsubmit clause.
7) method Optional parameter. Describes a method for action.
8) enctype Optional parameter. Describes an enctype parameter.

for downloading:

Library: lbalance.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: