Random content taglib ver. 1.3


    Custom JSP taglib. Tags let you to display different image or files from a group of files on every request to your page. So at the end of the day you will get a more dynamic look and feel to your website. For example:

1) Output the random image from the given directory:
 


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

<r:randomImage dir="/images"/>

2) Rotate files:
 


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

<r:rotateFile dir="/announces"/>

All tags do nothing if the source directory does not exist or this directory is empty.

Tags are:

randomImage

Tag mimics HTML img tag where the image will be randomly selected from the given directory. Parameters are:

1) dir Describes a directory with images (.gif, .jpg, .jpeg, .png .bmp files)
2) width Optional parameter. Describes a width for the image
3) height Optional parameter. Describes a height for the image
4) border Optional parameter. Describes a border.
5) alt Optional parameter. Describes an alternate text
6) align Optional parameter. Describes a position for the image
7) vspace Optional parameter. Describes a vertical margin for the image.

rotateImage

Tag mimics HTML img tag where the image will be selected from the given directory in rotation. Parameters are:

1) dir Describes a directory with images (.gif, .jpg, .jpeg, .png .bmp files)
2) width Optional parameter. Describes a width for the image
3) height Optional parameter. Describes a height for the image
4) border Optional parameter. Describes a border.
5) alt Optional parameter. Describes an alternate text
6) align Optional parameter. Describes a position for the image
7) vspace Optional parameter. Describes a vertical margin for the image.
8) scope Optional parameter. Possible values are session or application. Describes how to rotate files: per application or per user (session). Default value is session.

randomFile

Tag mimics jsp:include tag where the page will be randomly selected from the given directory. Parameters are:

1) dir Describes a directory with jsp files
2) flush Optional parameter. Possible values are true or false. Describes a flush toggle. Default value is false.

randomFiles

Body tag lets you include several random files from the given directory. Tag's body is a separator. Parameters are:

1) dir Describes a directory with jsp files
2) flush Optional parameter. Possible values are true or false. Describes a flush toggle. Default value is false.
3) count Optional parameter. Describes how many files should be included. Default value is 2.

rotateFile

Tag mimics jsp:include tag where the included page will be selected from the given directory in rotation. Parameters are:

1) dir Describes a directory with jsp files
2) flush Optional parameter. Possible values are true or false. Describes a flush toggle. Default value is false.
3) scope Optional parameter. Possible values are session or application. Describes how to rotate files: per application or per user (session). Default value is session.

for downloading:

Library: randomcontent.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: