Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java EE vs JSP vs JSF [closed]

Tags:

java

jsp

jsf

jsf-2

I am looking to learning a Java technology for developing web applications. As I looked more into this, I became confused between jsf, jsp, and javaee. 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 jsp or jsf?

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.

like image 769
Oliver Spryn Avatar asked May 17 '14 02:05

Oliver Spryn


People also ask

Is JSF better than JSP?

JSF is a proper framework that connects a data source with a reuseable UI component, provides support for multiple libraries, and decreases the effort to build and manage applications. Being component-based, JSF always has a good security advantage over JSP.

Is JSF part of Java EE?

Jakarta Server Faces (JSF; formerly JavaServer Faces) is a Java specification for building component-based user interfaces for web applications and was formalized as a standard through the Java Community Process being part of the Java Platform, Enterprise Edition.

Does JSF replace JSP?

JSF (JavaServer Faces) Since JSF 2.0, JSP has been deprecated as view technology in favor of Facelets. Note: JSP itself is NOT deprecated, just the combination of JSF with JSP is deprecated.

Is JSF part of J2EE?

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.


2 Answers

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.

like image 130
Evandro Pomatti Avatar answered Oct 02 '22 06:10

Evandro Pomatti


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 jsp or jsf?

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.

like image 28
Luiggi Mendoza Avatar answered Oct 02 '22 04:10

Luiggi Mendoza