I'm finishing on learning the Java language and looking to write very small web applications, since Facelets seems to be the replacement for JSP, and JSF seems overkill for small web apps, can I just learn Facelets and use it without the whole JSF stack? or should I just go with JSP for this small web apps?
It can be used without JSF. Just map the FacesServlet
on an URL pattern of *.xhtml
in web.xml
and do not declare
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
in any Facelet template. It actually don't harm to declare them, but this way you won't "accidentally" use them. You can as good write plain HTML in it and submit the form to a plain servlet and have the servlet forward/redirect to a Facelet.
You only need to keep in mind that with a servlet you end up with much more boilerplate code for gathering the request parameters, converting/validating them, maintaining and updating the model values, invoking the business actions, while all this repeated boilerplate code is unnecessary with a fullworthy JSF managed bean.
Also, you can't use Facelets with request based MVC frameworks which have only JSP taglibs available, like Struts, Spring MVC, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With