Java EE 6: JSF vs Servlet + JSP. Should I bother learning JSF?

前端 未结 5 1453
感动是毒
感动是毒 2020-12-24 02:05

I am trying to get familiar with Java EE 6 by reading http://java.sun.com/javaee/6/docs/tutorial/doc/gexaf.html. I am a bit confused about the use of JSF.
Usually, the w

相关标签:
5条回答
  • 2020-12-24 02:11

    JSF provide an abstraction layer with several responsibilities, but most important it handles all the messy details of HTML forms and transferring data back and forth between web pages and Java POJO beans (getX, setX methods), which is notoriously difficult to do right.

    It also provides navigation and in the latest incarnation in Java EE 6 rudimentary AJAX support is available allowing for simple updates of the web page as the user inputs data.

    You might find it easier to think of it as a way to avoid writing JavaScript yourself.

    0 讨论(0)
  • 2020-12-24 02:11

    JSF Framework targets to simplify development integration of web-based user interfaces. As @bozho stated you can mix JSP and JSF. However, the "view" component in JSF is facelets - which can be viewed as little UI widgets, which are more or less self contained with respect to DHTML styling and JavaScript event generation and call back.

    "Should I bother learning.. ?"

    Not sure. I haven't seen JSF picking up that much steam even though it was around (Atleast in theory) for last 5 years.

    0 讨论(0)
  • 2020-12-24 02:16

    If you like XML choose JSF. In case that you are an actionlistener fan doPost,doGet etc choose Servlet and JSP.

    0 讨论(0)
  • 2020-12-24 02:19

    JSF basically enables you to develop a web application with only model objects (JavaBeans) and views (JSP/XHTML pages). With "plain vanilla" JSP/Servlet you'll have to bring in a lot of code to control, preprocess, postprocess, gather data, validate, convert, listen, etc the HTTP request and response. And then I'm not talking about refactoring it to a high (abstract) degree so that you can also end up the same way as JSF does (just a JavaBean class and a JSP/XHTML page per use case).

    I've posted a more detailed answer on the subject before here: What is the difference between JSF, Servlet and JSP?

    0 讨论(0)
  • 2020-12-24 02:28

    In JSF uses one specific Servlet (the Faces Servlet) to handle all incoming requests and dispatch them to the appropriate beans.

    JSF is a component-based MVC framework, while JSP is a view technology.
    You can use JSP with JSF, although Facelets is the preferred view technology.

    0 讨论(0)
提交回复
热议问题