The BSF (Bean Scripting Framework) Tag Library enables JSP writers to write the code portion of their JSP in languages other than Java.
For a much more detailed description of BSF itself see http://alphaworks.ibm.com/tech/bsf, but here are a few key excerpts:
BSF supports both directions of scripting: in one case where the Java-side is in charge and runs/evaluates scripts at will, and in the other case the script runs and controls Java beans. Notice that while we use the word "bean", it is used loosely - BSF works with any Java object and not just a true bean.
BSF defines a set of JSP objects available as beans that are available for the scriptlet to use:
The BSF taglib also allows JSP writers to use multiple scripting languages within the same JSP document.
Follow these steps to configure your web application with this tag library:
bsf.tld) to the
/WEB-INFsubdirectory of your web application.
.jar) to the
/WEB-INF/libsubdirectory of your web application.
<taglib>element to your web application deployment descriptor in
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/bsf-2.0</taglib-uri> <taglib-location>/WEB-INF/bsf.tld</taglib-location> </taglib>
To use the tags from this library in your JSP pages, add the following directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/bsf-2.0" prefix="x" %>
where "x" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
The BSF tag library includes several tags, with the following characteristics:
This tag is the BSF taglib equivalent of the "<%" JSP tag. There is one required attribute, "language", which defines the language used in that section of the JSP. For example:
$out println "Hello world"
This tag is the BSF taglib equivalent of the "<%=" JSP tag. This is one required attribute, "language", which defines the language used in that section of the JSP. For example:
See the example JSP (
an example of the usage of the tags from this custom tag library.