JSF form not showing

My server is glass fish v3, my browser is firefox 3.6.3, and I am using Netbeans 6.8. My question is why the text box is not displayed in my browser. I see only the label.

<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>Lookup</title> </h:head> <h:body> <fieldset> <legend>Enter Your Customer ID</legend> <p>Legal ids are id001, id002, and id003.</p> <f:view> <h:form> Customer ID: <h:inputText value="#{bankForm.customerId}" /> <h:commandButton value="Show Current Balance" action="#{bankForm.findBalance}" /> </h:form> </f:view> </fieldset> </h:body> </html> 

Web .xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</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>*.jsf</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>pages/customer-lookup</welcome-file> </welcome-file-list> </web-app> 
+7
jsf jsf-2
source share
4 answers

You need to make sure that the request URL (as you type in the browser address bar) matches the url-pattern FacesServlet . That is, do not open the page http://example.com/context/page.xhtml , but open it http://example.com/context/page.jsf . Otherwise, the FacesServlet will not be called, and your XHTML page with JSF components will not be processed in any way. In the browser, you will only see "plain HTML" tags such as <fieldset> , etc., and you will see the JSF source code unchanged in the returned HTML source when you view the source in the browser.

+14
source share

Add this to your web.xml:

  <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> 
+7
source share

The problem you are facing can be solved in the web.xml file stored in the WEB-INF directory in the web application project. You need to open this file and add the following xml content so that the pages work correctly.

  <web-app> ... ... ... <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> </web-app> 

If your .xml file does not exist in the specified directory, you can add it by clicking on your web application project, add a new file and then select the standard deployment descriptor (web.xml)

+2
source share

Check if you configured Faces-Servlet on this page

0
source share

All Articles