It seems velocity and freemarker look fairly similiar, at least for basic usage.
Anyhow, what is the “built in” or standard view framework called?
It looks like:
<c:if test="${someobject.property != null}">
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s indeed JSTL. It’s however not builtin, but all you need to do is to just drop jstl-1.2.jar in the
/WEB-INF/liband declare one of its taglibs in top of the JSP page as per the TLD documentation, e.g. JSTL core:This way you can use the in the link listed tags. Most of the core tags are just flow control tags. JSTL also has XML and SQL taglibs, but they are intented for quick prototyping only and shouldn’t be used in real production. Then there is the Format (fmt) taglib which is great for internationalization and localization (i18n and l10n). Finally there is the useful functions (fn) taglib which provides simple EL functions.
Then there are the
${}things. This is called expression language. It just accesses “backend data” (the attributes) in any of the page, request, session and application scopes in a Javabean like way with help ofPageContext#findAttribute()and calling the Javabean getters. If you understand scriptlets, then you’ll understand the following example:which roughly resolves to
EL is nullsafe. When
${user}or${user.address}resolves tonull, then it will just skip it all and display nothing. In scriptlets you would have gotten a NPE on the nested calls or just plainnullon the last call.Then there is the unified EL, denoted by the
#{}syntax. It’s (as far) only used in combination with JavaServer Faces (JSF). It is able do to a call a Javabean setter on the last property. E.g.will behind the scenes roughly do like follows
It’s by the way not a view technology. JSP itself is already the view technology at its own. JSTL is just a taglib. EL is just part of the JSP spec. The other view technology provided by Java EE is Facelets which is XHTML based and provides much more seamless integration for JSF than JSP does.