32

I am looking to learning a Java technology for developing web applications. As I looked more into this, I became confused between , , and . I know there are several posts on SO (post 1, post 2) which attempt to resolve these confusions, I have a few more on top of them:

  1. Is JSP "dead" in favor of JSF?
  2. Is Java EE the platform JSF runs on top of or something different altogether?
  3. Is JSF merely an MVC framework for developing web applications?
  4. Is JSF a framework developed by Oracle and part of Java, or is it a separate framework altogether (Much like the Zend Framwork is from PHP)?
  5. [Bonus] Would you recommend learning or ?

In your answer, feel free to compare any of these technologies to things like ASP.NET, ASP.NET MVC, Ruby on Rails, Zend Framework, or regular-old Java Applets, as these are things I am already familiar with.

Thank you for your time.

Community
  • 1
  • 1
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
  • 1
    Both JSP and JSF are "dead" technologies. JSP comes from an era where scripting and making a mess of your HTML page was the norm (see the old-style PHP scripting). JSF tried to solve this issue by abstracting away the presentation aspect into components, but failed miserably because the presentation technologies moved too fast for it (Jquery, Bootstrap, Angular, Knockout etc.). The most maintainable approach now is the pure MVC using templates (Velocity, Freemarker etc.) which have their own MVVM cycles for AJAX using the modern JS stuff. Even PHP (Smarty, Twig etc.) evolved that way. – jbx Sep 17 '14 at 15:03
  • JSF is not "dead" at all, JSF 2.3 will be delivered in 2017 as part of Java EE 8, and not incompatible with jQuery or bootstrap. – Jose Manuel Gomez Alvarez Nov 01 '16 at 18:32

3 Answers3

37

Is JSP "dead" in favor of JSF?

JSF has countless benefits over JSP. For instance:

  • It defines a MVC approach
  • It set up componentization standards
  • It has apply values feature
  • Built-in AJAX
  • A defined view context control
  • Allows for rich interfaces extensions like Primefaces

And we can go on and on.

You can still use JSP for other scenarios where you need some specific flexibility or performance, and the same thing for servlets, but JSF pretty much replaced JSP for "robust" applications.

Now, I am a huge fan of JSF, but it has a long way to go. JSF 2.2 kinda looks like a mature framework now that it has a defined navigation standard (FacesFlow), and we just had a built-in file uploader in 2.1 and it is not even AJAX, and there's "HTML5", etc. So yeah, there is a lot more work to be done that I won't detail in here.

In my experience, JSP is in fact "dead" if compared to JSF and other frameworks like Spring MVC and others. Java EE 7 tutorial barely says anything about JSP. But it is not dead dead, since it is already supported in Web Containers and you can still use it.

Is Java EE the platform JSF runs on top of or something different altogether?

JSF is part of Java EE but you do not need full Java EE profile in order to use JSF. Examples:

  • Tomcat is just a Java EE Web Profile implementation, and you can use JSF in Tomcat.
  • You can use JSF in JBoss but you do not need JMS enabled in order to JSF to work.

Java EE components are modular, and you only need a Web Profile server/container in order to use JSF.

Is JSF merely an MVC framework for developing web applications?

Yes (but I wouldn't say merely). Each one has it own pros and cons. But the principle is the same.

One could argue about integration with EJB, but so is Spring MVC with its own container.

Is JSF a framework developed by Oracle and part of Java, or is it a separate framework altogether (Much like the Zend Framwork is from PHP)?

Oracle now delegates to teams to define specification. In theory, you can implement your own JSF if you want. I do not know about PHP's Zend Framework.

Most common JSF implementations are Mojarra and MyFaces. (Luiggi beat me on this right now, you can check his links).

[Bonus] Would you recommend learning jsp or jsf?

I would recommend both. JSP first and JSF after it.

But I would 100% recommend you to use JSF for you projects. But make sure you understand componentization and all the stuff that makes JSF a powerful tool.

Also check out JSF 2.2 new features, this page is awesome for an intro on the latest features added to the framework.

Rick-777
  • 9,714
  • 5
  • 34
  • 50
Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165
  • Thank you! That was very helpful for me to resolve these differences. – Oliver Spryn May 17 '14 at 04:56
  • 6
    Spring MVC still uses JSP as view technology. – Luiggi Mendoza May 17 '14 at 16:47
  • 1
    @LuiggiMendoza Spring MVC still supports JSP (and you find it a lot in books etc. because its what people most commonly are familiar with), but better templating technologies such as Velocity and Freemarker are recommended. – jbx Sep 17 '14 at 15:05
  • @jbx I agree. In fact, I use velocity for templating system but JSF 2 is easier for my use cases. – Luiggi Mendoza Sep 17 '14 at 15:08
  • 1
    I know the question is about JSP vs JSF, but why not use ReactJS, AngularJS or VueJS as view tier? They are rendered in client side, so for legacy systems may you will need look for server side rendered view, in that case, I will suggest thymeleaf. JSF is nice but you will be tied to JEE managed beans. – Cassio Seffrin Apr 25 '19 at 02:09
  • @CassioSeffrin I'm using 'modern' frameworks today for most projects and advise most people to do so, but JSF is still more productive in certain scenarios because of the integration with the container and intuitiveness of MVC. Examples are administrative consoles or utility web apps, which are secondary to the product itself. Teams that have no time, knowledge or budget can assemble a build with PrimeFaces and be running in no time, that's when JSF becomes the right tool for the job. – Evandro Pomatti Apr 25 '19 at 07:46
  • 1
    @EvandroPomatti I totally agree with you, I just pointed out new approaches because I believe it is relevant to discuss as alternatives to jsf/primefaces these days. JSF is still productive: yes, moreover, in cases of legacy systems, the new approaches may be out of context. On the other hand, "react" as a view layer make things much more powerful and allow developers to provide many interactive user interfaces, as well as alleviate extra server processing efforts by distributing them to their multiple clients. – Cassio Seffrin Apr 27 '19 at 18:10
15

Is JSP "dead" in favor of JSF?

No, it is still maintained for legacy and current web applications as view technology. Also, JSF works with JSP as view, but since JSF 2 it is better to use Facelets as the technology view. The reasons are explained here: Why Facelets is preferred over JSP as the view definition language from JSF2.0 onwards?. In short, Facelets supports pre and post processing of the content to render, while JSP doesn't.

Is Java EE the platform JSF runs on top of or something different altogether?

JSF can run by its own in any Java web application server. You just need to add the necessary libraries: JSF-api and JSF-impl.

Is JSF merely an MVC framework for developing web applications?

Yes. It doesn't provide any help for web service generation, connection pooling, transaction management, etc. It supports EJB injection through @EJB and parameters injection through @ManagedProperty, but that's all. You may use other frameworks to do the job: Hibernate, EJB, Spring, CDI, etc.

Is JSF a framework developed by Oracle and part of Java, or is it a separate framework altogether (Much like the Zend Framwork is from PHP)?

JSF is supported by by JSR 344. This specification is supported by the Java Community Process, which is supported by Oracle. From this, you can infer that at least Oracle provides an implementation for JSF. Since JSF is a specification, it can be implemented by other organizations as well. Currently, there's another implementation for JSF, MyFaces.

Would you recommend learning or ?

This is like asking should I learn how to create HTML or how to use a library set that will create HTML for me?. JSP is a technology made for the view of web applications that supports dynamic content by usage of Java technology. JSF is a MVC framework that helps you to ease the generation of the content in view (JSP or Facelets) and data binding through the view, controller and the model. You can learn both at the same time, and I recommend you to learn what you're currently using or what you will use. IMO you should learn both: JSF to develop JSF applications, and JSP to work with other MVC frameworks or to maintain current legacy applications built with JSP.

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
3

1.Is JSP "dead" in favor of JSF?

In the realm of JAVA EE JSP is announced "obsolete". In a wider world it is well alive.

2.Is Java EE the platform JSF runs on top of or something different altogether?

Depends on where is the "top". Servlets are the basement for most Java frameworks including JSF.

3.Is JSF merely an MVC framework for developing web applications?

Yes, it the sense that JSF is a presentation layer framework.

4.Is JSF a framework developed by Oracle and part of Java, or is it a separate framework altogether (Much like the Zend Framwork is from PHP)?

JSF is an official part of Java EE 7 by Oracle.

5.[Bonus] Would you recommend learning jsp or jsf?

Both, to a certain depth. Consider also HybridJava - its is same powerful as JSF but about twice simpler.

Dima
  • 1,326
  • 2
  • 13
  • 19