What is the difference between JSF, Servlet and JSP?

前端 未结 15 1865
北海茫月
北海茫月 2020-11-21 06:41

I have some questions. These are :

  1. How are JSP and Servlet related to each other?
  2. Is JSP some kind of Servlet?
  3. How are JSP and JSF related t
相关标签:
15条回答
  • 2020-11-21 07:04

    Jsp is also having in built servlet code which don't need any external compilation it can be run directly run. Changes will take effect in jsp directly in a browser.

    Servlet need to be compiled (i.e it will have specific class creation)

    Jsf is a view component of MVC Framework

    0 讨论(0)
  • 2020-11-21 07:05

    See http://www.oracle.com/technetwork/java/faq-137059.html

    JSP technology is part of the Java technology family. JSP pages are compiled into servlets and may call JavaBeans components (beans) or Enterprise JavaBeans components (enterprise beans) to perform processing on the server. As such, JSP technology is a key component in a highly scalable architecture for web-based applications.

    See https://jcp.org/en/introduction/faq

    A: JavaServer Faces technology is a framework for building user interfaces for web applications. JavaServer Faces technology includes:

    A set of APIs for: representing UI components and managing their state, handling events and input validation, defining page navigation, and supporting internationalization and accessibility.

    A JavaServer Pages (JSP) custom tag library for expressing a JavaServer Faces interface within a JSP page.

    JSP is a specialized kind of servlet.

    JSF is a set of tags you can use with JSP.

    0 讨论(0)
  • Servlets are the server side java programs which execute inside the web container. The main goal of the servlet is to process the requests received from the client.

    Java Server Pages is used to create dynamic web pages. Jsp's were introduced to write java plus html code in a single file which was not easy to do in servlets program. And a jsp file is converted to a java servlet when it is translated.

    Java Server Faces is a MVC web framework which simplifies the development of UI.

    0 讨论(0)
  • 2020-11-21 07:06

    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:

    Source

    0 讨论(0)
  • 2020-11-21 07:08

    From Browser/Client perspective

    JSP and JSF both looks same, As Per Application Requirements goes, JSP is more suited for request - response based applications.

    JSF is targetted for richer event based Web applications. I see event as much more granular than request/response.

    From Server Perspective

    JSP page is converted to servlet, and it has only minimal behaviour.

    JSF page is converted to components tree(by specialized FacesServlet) and it follows component lifecycle defined by spec.

    0 讨论(0)
  • 2020-11-21 07:15

    There are also situations where you can favor JSP over JSF. The application nature should be the deciding factor to choose the technology.

    If you have a rich GUI interaction and lot of Java scripting needed then favor JSF. Basically if your GUI app architecture is like Component oriented & even driven like Swing then JSF is the best.

    If the application is just a plain form submitting, not much of GUI interaction needed, then JSP could do well if learning a new tech is an overhead and also complex framework is unnecessary.

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