Primefaces charts Error - jsf

Hi Friends JSF primefaces charts not display i am using following .jar files in my application
1)primefaces-3.0.M1.jar
2)jstl-1.0.2.jar
3)jsf-impl.jar
4)jsf-api.jar
but i am getting below exception
org.apache.jasper.JasperException: /pieChartLive.jsp(16,34) #{..} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:711)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:935)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
My Jsp file (pieChartLive.jsp)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PieChartLive</title>
<p:resources />
</head>
<body>
<h:form id="livePieChartForm">
<p:pieChart id="votes" value="#{PieChartLiveBean.lunchSalesList}"
var="lunchSalesBean" live="true" refreshInterval="3000"
categoryField="#{lunchSalesBean.dishName}"
dataField="#{lunchSalesBean.salesPercentage}" />
</h:form>
</body>
My web.xml
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
PrimeFaces
pieChartLive.jsp
<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>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
My faces-config.xml
<faces-config>
<managed-bean>
<managed-bean-name>PieChartLiveBean</managed-bean-name>
<managed-bean-class>com.sample.primefaces.PieChartLiveBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

You are mixing jsp and facelets. Your facelet has file suffix .jsp but your web.xml mapping for the Faces Servlet is *.jsf. So the Faces Servlet won't be invoked.
Change the file suffix to .jsf and try again.

Related

Primefaces resources are not loaded

I'm using Primefaces 5.3 with TomEE, but I when I access my pages the PF resources are not being loaded and I get the following error:
$ is not defined
PrimeFaces is not defined
Even when I access the resource URL I get the following error
URL:
http://localhost:8080/Myapp/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo
Error:
XML Parsing Error: no root element found Location: http://localhost:8080/Myapp/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo Line Number 1, Column 1
My page :
<?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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<f:view>
<p:growl id="notificationMessage" showDetail="true" />
<p:panel id="basic" header="Basic" footer="Movie Details" style="margin-bottom:20px">
<h:panelGrid columns="1" cellpadding="10">
<p:outputLabel for="mbbData" value="Data Value: " />
<p:inputText id="mbbData" value="#{mbbDataInputController.mbbData}" required="true" />
<p:commandButton action="#{mbbDataInputController.addMbb}" />
</h:panelGrid>
</p:panel>
</f:view>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<display-name>my-service</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
WEB-INF/faces-config.xml
</param-value>
</context-param>
<!-- Faces Servlet -->
<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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>rest-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.huawei.myapp.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I also tried to add the following to the page head:
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
but it did not work.
Also please note that as I debugged the PrimeResourceHandler class, the resource are being created and the resource path is in the right jar.
OK, I found the problem and the solution as follows.
Problem:
The problem is that I am using two servlets, javax.faces.webapp.FacesServlet for JSF and org.glassfish.jersey.servlet.ServletContainer for REST web services. and when I requested reource file, actually Jersey servlet were going to serve it for me not the faces servlet.
Solution:
I changed the web.xml url mapping as:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/javax.faces.resources/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>rest-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>

How to separate head?

Here how look my .jspx files:
<?xml version='1.0' encoding='utf-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core">
<jsp:output omit-xml-declaration="true" doctype-root-element="HTML" doctype-system="http://www.w3.org/TR/html5"/>
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:loadBundle basename="my.pack.resource" var="r"/>
<f:loadBundle basename="my.pack.error" var="e"/>
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html utf-8"/>
<meta name="viewport" content="width=device-width"/>
<title> Some title </title>
<jsp:directive.include file="/temp/myLayout.jspf" />
</head>
<body>
<h:form>
<h:commandLink .........
</h:form>
</body>
</html>
</f:view>
</jsp:root>
In order to keep my view files clear and small
I would like to put all above and after body in
templates and include it in my .ispx files and pass title as parameter.
If anybody knows solution, please help.
EDIT
I have changed my view from .jspx to .xhtml, but my servlet filters now don't work.
Here my web.xml:
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app 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_2_5.xsd"
version="2.5">
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml;*.jsf</param-value>
</context-param>
<filter>
<filter-name>loginFilter</filter-name>
<filter-class>my.pack.filterpack.LoginFilter</filter-class>
</filter>
<filter>
<filter-name>remebermefilter</filter-name>
<filter-class>my.pack.filterpack.RemeberMeFilter</filter-class>
</filter>
<filter>
<filter-name>NoCacheFilter</filter-name>
<filter-class>my.pack.filterpack.NoCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/view/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>remebermefilter</filter-name>
<url-pattern>/login/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>NoCacheFilter</filter-name>
<url-pattern>*.xhtml</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- servlet mappings -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
<error-code>500</error-code>
<location>/index.jsp</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/viewExp.jsp</location>
</error-page>
<listener>
<listener-class>my.pack.timer.MyJobManager</listener-class>
</listener>
</web-app>
This is one of the reasons why JSP(X) is abandoned, deprecated and succeeded by Facelets 4 years ago. JSP(X) doesn't offer easy templating capabilities in order to achieve this kind of requirements.
Just migrate to Facelets. Rename .jspx to .xhtml and replace <jsp:xxx> tags by <ui:xxx> tags. Your functional requirement is answered in 2nd example of How to include another XHTML in XHTML using JSF 2.0 Facelets?
Facelets is natively available in JSF 2.x. If you're still using JSF 1.x, then you can just install it separately as per its documentation.

java.lang.NullPointerException at org.icepush.util.ExtensionRegistry.getBestExtension

I made a new IceFace project and tried to run it on my local host, however I got the following error message:
Nov 4, 2013 11:41:10 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFO: Monitoring file:/Users/Alex/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/TEST/WEB-INF/faces-config.xml for modifications
2013-11-04 23:41:10.563:INFO:oejs.AbstractConnector:Started SelectChannelConnector#0.0.0.0:8080
2013-11-04 23:41:11.623:WARN:oejh.HttpGenerator:Ignoring extra content <html>
<head>
</head>
<body>
</body>
</html>
Nov 4, 2013 11:41:11 PM org.icefaces.impl.application.ExtendedExceptionHandler handle
WARNING: queued exception
java.lang.NullPointerException
at org.icepush.util.ExtensionRegistry.getBestExtension(ExtensionRegistry.java:69)
at org.icefaces.impl.push.servlet.ICEpushResourceHandler$ICEpushResourceHandlerImpl.beforePhase(ICEpushResourceHandler.java:171)
at org.icefaces.impl.push.servlet.ICEpushResourceHandler.beforePhase(ICEpushResourceHandler.java:111)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:368)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool
and here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TEST</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
<url-pattern>*.jsf</url-pattern>
<url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.coalesceResources</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.strictSessionTimeout</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.ace.gmapKey</param-name>
<param-value>AIzaSyAATyWVqT2qNusNGmcVTyQ0QmymkpU-B5o</param-value>
</context-param>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
</web-app>
The two files I have under my WebContext is index.jsp which redirects to index.jsf and the other file is index.xhtml which contains the following :
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
>
<h:head>
<title>ICEfaces 3</title>
</h:head>
<h:body>
<h:form id="iceForm">
<ace:panel header="Welcome to ICEfaces">
<h:panelGrid columns="1">
<ace:linkButton id="linkButton1" value="ICEfaces Overview" href="http://wiki.icesoft.org/display/ICE/ICEfaces+Overview"></ace:linkButton>
<ace:linkButton id="linkButton2" value="General Documentation" href="http://wiki.icesoft.org/display/ICE/ICEfaces+Documentation"></ace:linkButton>
<ace:linkButton id="linkButton4" value="Tutorials" href="http://www.icesoft.org/community/tutorials-samples.jsf"></ace:linkButton>
<ace:linkButton id="linkButton5" value="ACE components" href="http://wiki.icesoft.org/display/ICE/ACE+Components"></ace:linkButton>
</h:panelGrid>
</ace:panel>
</h:form>
</h:body>
</html>
i have tried switching the the welcome-file-list to
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file> <!--switched extension from html to xhtml -->
<welcome-file-list>
with this change my localhost will not crash, however I get a blank page (none of my JSF element shows up) I'm having a feeling it is because none of my JSf tags are getting parsed, however i don't really know where the problem is, can anyone please help me?
other information:
Im using Eclipse Java EE IDE for Web Developers
ICEFACES 3.3.0
Tomcat 3.0
Thanks.
update:
Changed my web.xml welcome-file-list to
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
and changed my servlet-mapping to
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
There is no crash now, but my JSF elements does not show up, i only get a blank page.
UPDATES:
Web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
I have tried .jsf and .xhtml inside the url-pattern tag both no luck
index.jsp
<html>
<head>
</head>
<body>
<%
//response.sendRedirect("./index.jsf");
%>
<jsp:forward page="main.jsf"/>
</body>
</html>
after Getting my page to load up, it becomes blank, so i right click on my page and view source, and this is what i found...
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
>
<h:head>
<title>ICEfaces 3</title>
</h:head>
<h:body>
<h:form id="iceForm">
<ace:panel header="Welcome to ICEfaces">
<h:panelGrid columns="1">
<ace:linkButton id="linkButton1" value="ICEfaces Overview" href="http://wiki.icesoft.org/display/ICE/ICEfaces+Overview"></ace:linkButton>
<ace:linkButton id="linkButton2" value="General Documentation" href="http://wiki.icesoft.org/display/ICE/ICEfaces+Documentation"></ace:linkButton>
<ace:linkButton id="linkButton4" value="Tutorials" href="http://www.icesoft.org/community/tutorials-samples.jsf"></ace:linkButton>
<ace:linkButton id="linkButton5" value="ACE components" href="http://wiki.icesoft.org/display/ICE/ACE+Components"></ace:linkButton>
</h:panelGrid>
</ace:panel>
</h:form>
</h:body>
</html>
Any ideas why this is happening?

JSF h tags not displaying [duplicate]

This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 5 years ago.
Using Netbeans to deploy a web app on Glassfish 3.1.2.2 and none of my h tags display on the web. For instance:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>Draft Savvy Beers</title>
</head>
<h:form>
<h:body>
<h1>Search for beers</h1>
<p><strong>Would you like to search for a beer?</strong>
<h:inputText value="#{draftSavvyController.searchTerm}" />
<h:commandButton value="#{draftSavvyController.searchforBeers}" /></p>
</h:body>
</h:form>
</html>
displays only the text, no input field or button. Using plain old html shows the fields and buttons obviously, but I can't access my controller this way. Here is my 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>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</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>login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Let me know if I can provide anymore info. I'm pretty new at this...
Add this to your web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
I think the cause of the problem is that the request is not being passed through the FacesServlet.
The page URL did not match the url-pattern of the FacesServlet, thus it had not any chance to parse the tags.

JSF Form is not showing up [duplicate]

This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 7 years ago.
My server is glassfish v3, my browser is firefox 3.6.3 and i am using Netbeans 6.8
My question is why the textfield is not showing up in my browser. I only see 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>
The 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>
You need to make sure that the request URL (as you enter in browser address bar) matches the url-pattern of the FacesServlet. I.e. do not open the page by http://example.com/context/page.xhtml, but open it by http://example.com/context/page.jsf. Otherwise the FacesServlet will not be invoked and your XHTML page with JSF components will not be parsed in any way. You'll only see "plain HTML" tags like <fieldset> and so on in the browser and you will see the JSF source code unchanged in the returned HTML source when you do a View Source in browser.
Add this to your web.xml :
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
The problem you faced with may be solved in web.xml file stored in the WEB-INF dir in your web application project. You need to open that file and add the following xml content in order to make your pages running properly.
<web-app>
...
...
...
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
If your .xml file doesnt exist in the mentioned dir, you can add it by clicking on your web application project, add new file and then choose Standard Deployment Descriptor (web.xml)
Check if you have configured Faces-Servlet on this page

Resources