JSF%20Interview%20Questions%20and%20Answers
Question: How do I configure the configuration file?Answer: The configuration file used is our old web.xml, if we use some IDE it will be pretty simple to generate but the contents will be something like below:<?xml version="e;1.0"e; encoding="e;UTF-8"e;?> <web-app version="e;2.4"e; xmlns="e;http://java.sun.com/xml/ns/j2ee"e; xmlns:xsi="e;http://www.w3.org/2001/XMLSchema-instance"e; xsi:schemaLocation="e;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"e;> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file> index.jsp </welcome-file> </welcome-file-list> </web-app> The unique thing about this file is ?servlet mapping?. JSF pages are processed by a servlet known to be part of JSF implementation code. In the example above, it has extension of .faces. It would be wrong to point your browser to http://localhost:8080/MyJSF/login.jsp, but it has to be http://localhost:8080/MyJSF/login.faces. If you want that your pages to be with .jsf, it can be done with small modification :-), <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> <servlet-mapping> |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is JSF?
- What is required for JSF to get started?
- What is JSF architecture?
- How the components of JSF are rendered? An Example
- How JSF different from conventional JSP / Servlet Model?