tags:

views:

837

answers:

1

Hello everyone.

I'm new to Web Development, so please be patient with me. This might be a dumb question, but I need to get these terms clear in my head!

I just started reading the Java EE 6 Tutorial, and I'm a little confused! I knew about JavaServer Pages (JSP), and even did some coding during my undergraduate studies. But now, in this tutorial, I don't see anything about JSP.

Instead I read about Facelets, a new View Definition Framework (as it is described in this tutorial). I searched a little bit over the Internet to clarify the distinction between JSP and Facelets, and I came across with this post that helped me a lot (especially BalusC's answer). But these terms are still a little unclear to me.

What is the difference between JSP and Facelets? Are Facelets going to replace JSP, or is it just a technology that works better with JSF (and if it's the latter, why)? If they are different, when should I use each one of them?

Thank you in advance for all your answers.

+3  A: 

As you can read from the tutorial,

The term Facelets is used to refer to the JavaServerTM Faces View Definition Framework, which is a page declaration language that was developed for use with JavaServer Faces technology. As of JavaServer Faces 2.0, Facelets is a part of JavaServer Faces specification and also the preferred presentation technology for building JavaServer Faces based applications.

Now, JSP is the standard view technology for the web. But when it comes to adopt JSF as a web framework, JSP doesn't support all the features provided in JSF 2.0. Therefore, there was a need of some standard view technology to work with JSF 2.0. So, Facelets is just that.

If you are not working with JSF at all, you don't need to employ Facelets. You can go with JSP in that case. Or there are few other template frameworks, like FreeMarker, and Velocity. Moreover, some web frameworks, defines there own mark-up, like Struts2. So if you decided to go with Struts, using Struts mark-up is the way to go.

Adeel Ansari
To avoid confusion and to grasp clear understanding, I would suggest you to learn JSP, anyway. After that you will automatically be able to see yourself. JSP is not obsolete, and is still used as a view technology in many Java web applications.
Adeel Ansari
So, if I understand correctly, both Facelets and JSP (and other mark-ups) are ways to put data (either by using beans or do some other operations) into web pages, right? And the choice of which one you should use depends solely on the framework. Am I correct?
Alex
Yes, sort of. Why sort of? Because there are a lot of frameworks that doesn't introduce anything of there own, and are content with JSP, plus there own taglib. So, JSP is still in great use. The case of JSF, and alike, frameworks is a bit different. JSF differs in style. It does things in terms of components. Tapestry is another, not very familiar with Tapestry though.
Adeel Ansari
Thank you very much Vinegar. I finally understood it! :) Even though I don't see the point of all these great numbers of Java frameworks that are out there....!
Alex
IMO, after these rapid web application frameworks like, Django and Rails, the Java community started thinking of something similar in ease of development and have the potential to cut down on development time. So we end up having hell lot. Every other framework is to attract a particular kind of minds/developers. Like Wicket is more towards Java Developers. Few others are designers friendly, Tapestry claims that. Struts2 came because Struts was bloated. Spring comes to make our life easier. Struts was the first Java web framework, AFAIK. There are many more, choosing one is indeed difficult.
Adeel Ansari