Using the Expression Language in your custom tags

JSTL is great for eliminating scriptlets in your JSPs. The standard JSTL tags are designed to be general purpose, applicable and useful in many different applications. But frequently you need to create your own custom tags to meet the needs of your specifc application. To really take advantage of the JSTL you need to make your custom tags work in conjuction with the JSTL. For instance, you may want to use the ‘forEach’ tag provided by the JSTL and have your custom tag nested inside the forEach loop. Inside the loop you want to have your tag interact with the variable that is exposed by the ‘var’ attribute of the forEach tag. You can accomplish this by giving your custom tag the ability to evaluate expressions written in the JSTL’s expression language.

If you are working with JSP 2.0, the expression language is part of the servlet specification and you can find the classes for evaluating expressions in the javax.servlet.jsp.el package.

If you haven’t stepped up to JSP 2.0 yet and you’re working with JSTL 1.0 you can use the class found in the Jakarta taglibs standard.jar file.

This entry was posted in General. Bookmark the permalink.

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/5/d154205736/htdocs/wordpress/wp-includes/class-wp-comment-query.php on line 405

Comments are closed.