JSF VS Faclets VS JSP

关于 JavaServer面孔与所谓的 脸谱之间的具体区别,我似乎无法得到一个明确的答案。有人能给我一个明确的答案吗? ! ?

另外,我知道 JSF 或者 JSP 都可以用来创建动态网页,但是两个看似矛盾的细节让我很困惑。我听过以下两种说法:

  1. JSF 是 JSP 的替代品;

  2. 在 Java 的 web 层 MVC 范式中,JSF 和 JSP 构成了 观景的不同部分

那么到底是什么呢? 逻辑告诉我们,几乎可以肯定的是,不可能两者兼而有之!

81063 次浏览

From Wikipedia article(JSF)

JSF is a request-driven MVC web framework based on component driven UI design model, using XML files called view templates or Facelets views.

JSF is web framework and Facelet is a view template for JSF

From Wikipedia article(JSP)

JavaServer Pages (JSP) is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML,

Also look at this topic Difference between jsf and jsp

  • JSF is a standardized Java framework for web UIs based on an MVC pattern
  • JSPs are a (much older) standard for generating web pages from templates - these can be used as the View in a JSF application, but also separately from JSF.
  • Facelets are an alternative view technology based on pure XML templates (no scriptlets) which was introduced with Version 2 of the JSF standard. They can only be used in a JSF application.

In the light of that, let's take a look at your conflicting statements:

That JSF is a replacement for JSP; and

Not quite true, since JSF can use JSPs for its view (and had to, prior to JSF 2). However, JSF apps using Facelets can be seen as a replacement for JSP-based technologies.

JSF and JSP form different parts of the View in Java's web-tier MVC paradigm

Completely wrong - JSF covers the entire MVC pattern (though it can overlap with EJBs, since both are based on annotations that can be mixed in the same class).

I've been looking for an answer for the same question. I found these links very helpful:

An Example of JSP application model: http://netbeans.org/kb/docs/javaee/ecommerce/design.html#architecture

Basic JSF Concepts, some by examples: http://netbeans.org/kb/docs/javaee/ecommerce/conclusion.html#framework

Java Server Pages (JSP) is java technology which enables Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems. JSP technology separates the user interface from content generation, enabling designers to change the overall page layout without altering the underlying dynamic content.

Facelets is the first non JSP page declaration language designed for JSF (Java Server Faces) which provided a simpler and more powerful programming model to JSF developers as compare to JSP. It resolves different issues occurs in JSP for web applications development.

Here is a table that compares the features of scriplets and facelets:

enter image description here Source