JSTL stands for JavaServer pages Standard tag library, which was created to help JSP developer with common tasks e.g. iterating over Collection in JSP, printing values, encoding URLs etc. In order to use JSTL tags in JSP page you need to do things, first you need to add standard.jar and jstl.jar in your Web application's classpath. This you can do by putting these two jar files into WEB-INF/lib directory. Once you do this you need to import the JSTL tag library in your JSP page to use JSTL tags like out, foreach, or forTokens etc.
In order to import JSTL tags, you can use taglib directive, it takes two attribute prefix and uri. Prefix is something you define and use when you refer to any tag form tag library. The standard convention is to use "c" as a prefix for the JSTL core tag library.
Secon attribute uri is the value of "uri" field in your .tld file (tag library descriptor), the standard value for JSTL core tag library is "https://java.sun.com/jstl/core". Once you have done this, you can use any tag from the given tag library. JSTL has a different tag libraries for different functionality e.g. core contains most important tags for common functionality e.g. printing, iterating over collection etc. Now, lets understand how this whole thing work
What is the JSTL tag library?
Why use the JSTL tag library?
How JSTL tag library works?
JSTL core tag library example
That's all about how to use the JSTL tag library in JSP pages.
No comments:
Post a Comment
Feel free to comment, ask questions if you have any doubt.