I saw some examples creating the JSF pages with .jsp extension, other examples creating them with .xhtml extension, and other examples choose .jsf.I just would like to know what the difference is between above extensions when working with JSF pages, and how to choose the appropriate extension?
JSP is an old view technology and widely used in combination with JSF 1.x. Facelets (by some people overgeneralized as XHTML) is the successor of JSP and introduced as default view technology of JSF 2.x at end of 2009. When you were seeing JSPs, you were perhaps reading outdated books, tutorials or resources targeted on JSF 1.x. You should generally ignore them when developing with JSF 2.x and head to resources targeted on JSF 2.x, otherwise you may end up in confusion because many things are done differently in JSF 2.x on Facelets.
The *.jsf is just one of widely used URL patterns of the FacesServlet mapping in web.xml. Other ones are *.faces and /faces/*, but those are from back in the JSF 1.0/1.1 ages. They all do not represent the concrete file extension/path, but just a virtual file extension/path and is to be specified in URLs only like so If you are familiar with basic Servlets, then you should know that the servletcontainer will invoke the servlet when the request URL matches the servlet's URL pattern. So when the request URL matches *.jsf, then the FacesServlet will be invoked this way. When using JSPs, it would actually execute page.jsp. When using Facelets, this would actually compile page.xhtml.
Since JSF 2.x you can also use *.xhtml as URL pattern. This way you don't need to get confused when specifying URLs. Using *.xhtml as URL pattern was not possible in JSF 1.x with Facelets 1.x, because the FacesServlet would then run in an infinite loop calling itself everytime. An additional advantage of using *.xhtml is that the enduser won't be able to see raw JSF source code whenever the enduser purposefully changes the URL extension in browser address bar from for example .jsf to .xhtml. It is not possible to use *.jsp as URL pattern, because this way the container's builtin JspServlet, which is already using that URL pattern, would be overridden and then the FacesServlet wouldn't be able to feed on JSPs anymore.
Other extension mappings (*.jsf, *.faces) tend to be used for processing requests via the FacesServlet. This is a logical mapping to the view which the JSF runtime will handle. How mappings are handled is defined in the web.xml (that doesn't have to be done using extensions; the /faces/* mapping is often used.
All requests to a web application are mapped to a particular servlet based on matching a URL pattern (as defined in the Java Servlet Specification) against the portion of the request URL after the context path that selected this web application. JSF implementations must support web application that define a that maps any valid url-pattern to the FacesServlet. Prefix or extension mapping may be used. When using prefix mapping, the following mapping is recommended, but not required:
In addition to FacesServlet, JSF implementations may support other ways to invoke the JavaServer Faces request processing lifecycle, but applications that rely on these mechanisms will not be portable.
Been try to learn JSF, and sometimes I see the URL is *.jsf and sometimes is *.xhtml or /faces/*. Can someone fill my knowledge, please? When I create a JSF using Facelet, the file extension is .xhtml, so where does .jsf URL extension come from?
If you invoke this page with the .jsf extension, e.g. :8080/webapp/page.jsf then the FacesServlet will be invoked, locate the page.xhtml file and parse/render its JSF components. If the FacesServlet isn't invoked, then the enduser would end up getting the raw XHTML source code (which can be seen by rightclick, View Source).
Sometimes a *.faces extension or /faces/* foldermapping is been used. But this was from back in the JSF 1.0/1.1 ages. You're free to choose and use whatever mapping you'd like to let FacesServlet listen on, even if it's a nothing-saying *.xyz. The actual page itself should always have the .xhtml extension, but this is configureable by the following in web.xml:
More recently, with JSF/Facelets 2.0 a *.xhtml mapping is been used. In JSF/Facelets 1.x it was not possible to use the same mapping extension as the physical file. It would result in an infinite loop. But since JSF/Facelets 2.0 it is possible and this allows you to call the page by :8080/webapp/page.xhtml.
This way you don't need to configure some security restrictions to hide the raw source files away for cases whenever the enduser changes for example .jsf in URL to .xhtml in browser address bar. Only tooling (IDEs and plugins) and learning resources still need to catch up the advocated move from *.jsf to *.xhtml. As per JSF 2.3, the FacesServlet will by default be autoregistered on *.xhtml too (next to /faces/*, *.faces and *.jsf). This is backported to Mojarra 2.2.11.
Your portfolio is carefully tailored to align with your current financial position, personal needs and risk tolerance. We strive to preserve, protect and grow your assets while maintaining a steady hand through any market environment.
Blending planning and investment management, our private wealth services offer sophisticated advice for complex financial needs and priorities. Primarily for ultra-high net worth and institutional clients.
JSF Financial is an SEC-registered investment adviser; however such registration does not imply a certain level of skill or training and no inference to the contrary should be made. This website is being provided for informational purposes only and should not be considered investment advice or a reccomendation to buy or sell any securities. Securities offered through NewEdge Securities, Inc. member FINRA/SIPC. Financial advice is offered through JSF Financial, LLC, a Registered Investment Adviser. JSF Financial, LLC is not a subsidiary or control affiliate of NewEdge Securities, Inc.
Check the background of our investment professionals on FINRA's BrokerCheck finra.orgsipc.orgForm CRSDisclosuresPrivacy PolicyTerms Of Use
JSF Financial, LLC 2020 wp.i18n.setLocaleData( 'text direction\u0004ltr': [ 'ltr' ] ); var wpcf7 = "api":"root":"https:\/\/www.jsffinancial.com\/wp-json\/","namespace":"contact-form-7\/v1";