I've a problem with JSF 1.1 (dinosaur, I know)
So there are two pages - index.jsp and test.jsp
I want to be redirected from index.jsp to test.jsp after clicking "Create" button
But nothing happens:/
p.s. and, in general, how do I log the things there, right know there is even no log of the clicking event! it's horrible
index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%-- jsf:pagecode language="java" location="/src/pagecode/Index.java" --%><%-- /jsf:pagecode --%>
<%#page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<html>
<head>
<title>index</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="GENERATOR" content="IBM WebSphere Integration Developer 6.2">
<link rel="stylesheet" type="text/css" title="Style"
href="theme/stylesheet.css">
</head>
<f:view>
<body>
<h:panelGrid columns="1" width="12%" cellpadding="10" rendered="true">
<h:commandButton value="Create" action="#{Controller.create}" />
</h:panelGrid>
</body>
</f:view>
</html>
Controller.java
public class Controller extends PageCodeBase {
public String create() {
return "success";
}
}
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>Controller</managed-bean-name>
<managed-bean-class>pagecode.Controller</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>index</display-name>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/test.jsp</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>test.jsp</welcome-file>
</welcome-file-list>
The JSF <h:commandButton> generates a HTML <input type="submit"> element which works only when nested in a HTML <form> element whose JSF equivalent is <h:form>.
However, you don't have a <h:form> anywhere in your view. Add it accordingly:
<h:form>
<h:commandButton value="Create" action="#{Controller.create}" />
</h:form>
By the way, if all your create method does is returning a fixed outcome, then you can also just specify the outcome directly in the action attribute:
<h:form>
<h:commandButton value="Create" action="success" />
</h:form>
By the way #2, using POST for page-to-page navigation is a bad practice, you should prefer output links for this.
See also:
commandButton/commandLink/ajax action/listener method not invoked or input value not updated - point 1
The create method should return a string. This string is the path to the page where you want to redirect.
Replace:
return "success";
For:
return "yourpage"
Related
I have a button, when i click a modal panel opened - it's work fine. Now i tried to add a button to hide the panel - it's work also, but the problem is when i tried to show a text "panel closed" after button click it doesn't work. I use Jsf 1.2 and richfaces 3.3.3.
I have the following error message:
org.apache.jasper.el.JspELException: /index.jsp(35,7) 'javascript:Richfaces.hideModalPanel('myModalPanel');#{welcomeBean.showText(true)}' Method not found: class com.firstjsf.backingbeans.WelcomeBean.showText(java.lang.Boolean) at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:123)
above the code:
index.jsp
<%#taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%#taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%# taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%# taglib uri="http://richfaces.org/rich" prefix="rich"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<f:view>
<h:form>
<rich:panel>
<f:facet name="header">
<h:outputText value="Product"></h:outputText>
</f:facet>
<h:form>
<a4j:commandButton
id="newWid"
value="New Widget..."
immediate="true" ajaxSingle="true"
reRender="text"
oncomplete="javascript:Richfaces.showModalPanel('myModalPanel');"
styleClass="verboseButton noprint" />
</h:form>
<rich:modalPanel id="myModalPanel">
<f:facet name="header">
<h:outputLabel value="123" />
</f:facet>
From Modal Panel
<a4j:commandButton value="Hide" id="btn_hide"
oncomplete="javascript:Richfaces.hideModalPanel('myModalPanel');#{welcomeBean.setShowText(true)}" />
</rich:modalPanel>
<h:outputText id="text"
value="Panel closed"
rendered="#{helloMessage.showText eq true}">
</h:outputText>
</rich:panel>
</h:form>
</f:view>
</html>
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>welcomeBean</managed-bean-name>
<managed-bean-class>com.firstjsf.backingbeans.WelcomeBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>helloMessageBean</managed-bean-name>
<managed-bean-class>com.firstjsf.backingbeans.HelloMessageBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<description>Welcome page to message page</description>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>helloMessage</from-outcome>
<to-view-id>/message.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<description>Welcome page to message page</description>
<from-view-id>/message.jsp</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
BeanAction
public class WelcomeBean {
private boolean showText =false;
public String sayHello(){
return "helloMessage";
}
public boolean isShowText() {
return showText;
}
public void setShowText(boolean showText) {
this.showText = showText;
}
}
You're mixing JavaScript and EL expressions, #oncomplete is for executing JavaScript, if you want to do something on the server use #action or #actionListener. Otherwise the expression will be evaluated and the browser will try to execute the return value as if it was JavaScript.
By the way, your code shows you're using setShowText(true) (which is correct), but the exception says you're using just showText(true), which is it then?
I have to maintain an existing enterprise web application which is based on JSF 1.1 and Ajax4JSF. I want to add an asynchronous standard validation to an existing input field using <a4j:support>. It boils down to the below code snippet:
<%# page contentType="text/html; charset=ISO-8859-1" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Validate Test</title>
</head>
<body>
<f:view>
<h:form>
<h:inputText value="42" id="fooInput" required="true">
<a4j:support event="onchange" reRender="fooMsg" immediate="true" ajaxSingle="true"/>
<f:validateDoubleRange minimum="10" maximum="500"/>
</h:inputText>
<h:message for="fooInput" id="fooMsg" style="color: red;"/><br/>
<h:inputText value="Bar" id="barInput">
</h:inputText>
</h:form>
</f:view>
</body>
</html>
But the Ajax request is not fired. The following JS error is thrown:
TypeError: element.selectNodes is not a function
at Object.A4J.AJAX.XMLHttpRequest.getElementsByTagName (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:32:19)
at Object.A4J.AJAX.XMLHttpRequest._appendNewElements (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:43:389)
at Object.A4J.AJAX.XMLHttpRequest.appendNewHeadElements (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:43:185)
at Object.A4J.AJAX.processResponse [as onready] (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:57:731)
at XMLHttpRequest._request.onreadystatechange (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:20:25)
I have also tried to change both the "immediate" and the "ajaxSingle" attribute, but it did not change anything. The Ajax request does not get fired. Other Ajax4JSF features in the web application seem to work. What is the problem is and how can I solve it?
I am trying to do a simple test before I dive into a large activity. But, here is where I was stuck. The test is to submit the JSF form, but the managed bean action never gets triggered.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<f:view>
<head>
<title>A B C</title>
</head>
<body>
<h:form id="test">
<h:inputText value="demo"/>
<h:commandButton type="submit" value="A button" action="#{User.better}" immediate="true" />
</h:form>
</body>
</f:view>
</html>
Here is my managed bean
public class User {
public String send() {
System.out.println("Submitting data.....");
return null;
}
public void better() {
System.out.println("In better...");
}
}
I have set all the configurations correctly. I could be able to see the page. But,the control never gets into action method. How come? Any suggestions would be great.
UPDATE:
Here is my faces-conig.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" 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-facesconfig_1_2.xsd">
<application>
<view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
</application>
<managed-bean>
<managed-bean-name>User</managed-bean-name>
<managed-bean-class>com.srk.beans.User</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
I have changed the managed-bean-name from User to user(small case) and changed the same in the .xhtml page as well, but seems to be same problem still.
Try user instead of User.Thus, try put user.better instead of User.better. Are you using jsf 2 or no? Also, post your faces-config file
Support for an action method with a void return type did not show up in JSF until v2.x. You must specify a return type of at least Object for better
public Object better() {
System.out.println("In better...");
return null;
}
This question already has an answer here:
java.lang.RuntimeException Cannot find FacesContext
(1 answer)
Closed 7 years ago.
I'm new to JSF as i have started creating JSF app one week before i'm getting this exception
java.lang.RuntimeException: Cannot find FacesContext
i'm using Eclipse INDIGO
I'have tried with url pattern /faces/*, faces/HelloWorld.jsp, jsf/HelloWorld.jsp
can anyone tell me that which url we have to use when...??
my
web.xml
<display-name>JSFTutorial</display-name>
<welcome-file-list>
<welcome-file>HelloWorld.jsp</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>/jsf/*</url-pattern>
</servlet-mapping>
my faces.config.xml
<?xml version="1.0" encoding="UTF-8"?>
<managed-bean>
<managed-bean-name>helloWorldBean</managed-bean-name>
<managed-bean-class>com.myhomepageindia.jsftutorial.web.bean.HelloWorldBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>HelloWorld</display-name>
<from-view-id>/HelloWorld.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/HelloWorldResult.jsp</to-view-id>
</navigation-case>
</navigation-rule>
my Managed bean
package com.myhomepageindia.jsftutorial.web.bean;
public class HelloWorldBean {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getCompleteName() {
return this.firstName + " " + this.lastName;
}
public String sayHelloWorld() {
return "success";
}
}
HelloWorld.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%#taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%#taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<%
try {
%>
<f:view>
<p>
<h:message id="errors" for="firstName" style="color:red" />
<h:message id="errors1" for="lastName" style="color:red" />
</p>
<h:form>
<h:outputText value="First Name"></h:outputText>
<h:inputText id="firstName" value="#{helloWorldBean.firstName}"
required="true"></h:inputText>
<h:outputText value="Last Name"></h:outputText>
<h:inputText id="lastName" value="#{helloWorldBean.lastName}"
required="true"></h:inputText>
<h:commandButton action="#{helloWorldBean.sayHelloWorld}"
value="Get Complete Name"></h:commandButton>
</h:form>
</f:view>
<%
} catch (Exception e) {
out.println(e);
}
%>
</body>
Based in your web.xml configuration, you should call the pages under "/jsf/" to made them work with the Faces Servlet. There are two possible solutions for this:
Make sure you're accesing your pages like this http://your.domain.com/YourProject/jsf/anyPAge.jsp
Try changing the configuration in your web.xml to something like
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
Then access your page like http://your.domain.com/YourProject/jsf/anyPAge.jsf
Note for the last option: if you're using JSF 1.x, you must not use *.jsp as the url-pattern, it will give you a huge error explained here: Help with JSF 1.2 + Jboss 5.1.0 (it doesn't mind if you'reusing Tomcat, you will have the same error). If you're using JSF 2.x, then there will be no problem, and you should be using Facelets (those pages with xhtml extension) as explained here: What is the difference between JSF and Facelets?
A very simple way to test if JSF is working in your project is to make this simple page:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%#taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%#taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<f:view>
<h:outputText value="Hello world!" />
</f:view>
</body>
</html>
If this page gives you errors, then there must be something else in your project or in your application server that is blocking the Faces Servlet.
Make sure you have all the correct Jars on your classpath.
Change the following things in your code:
Change your url-pattern in web.xml to *.jsf.
Wrap all your html code inside <f:view> tags
<%# page pageEncoding="UTF-8" %>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!doctype ... >
<f:view>
<html>
...
</html>
</f:view>
Now your URL should be:
localhost:8080/JSFTutorial/HelloWorld.jsf
Hope this helps!
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
What works for me is to just omit using the Taglib in my jsp file and move them into the html tag such as
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</body>
</html>
Becomes
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head><title>Simple jsp page</title></head>
<body>
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</body>
</html>
I am to do a web application with JSF, just to get and put a value from the JSF to bean and vice versa. I think I have done everything properly but when I start the server and try to access my first page I get the following error
SEVERE: Servlet.service() for servlet [jsp] in context with path [/SimpleJSF] threw exception [/greeting.jsp (line: 20, column: 85) #{...} is not allowed in template text] with root cause
org.apache.jasper.JasperException: /greeting.jsp (line: 20, column: 85) #{...} is not allowed in template text
I am using Eclipse Helios with JDK 1.6 , apache Tomcat 7 and JSF 2.0 framework
Here is my code snippet
greeting.jsp
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Guess Number Facelets Application</title>
</h:head>
<h:body>
<h:form>
<h2>
Hi, my name is Duke. I am thinking of a number from
0 to 10.
Can you guess it?
</h2>
<p><h:inputText id="userNo" title="Type a number from 0 to 10:" value="#{resultNumber.userNumber}">
<f:validateLongRange minimum="#{resultNumber.minimum}" maximum="#{resultNumber.maximum}"/>
</h:inputText>
<h:commandButton id="submit" value="Submit" action="response.jsp"/>
</p>
<h:message showSummary="true" showDetail="false" style="color: #d20005; font-family: 'New Century Schoolbook', serif; font-style: oblique; text-decoration: overline"
id="errors1"
for="userNo"/>
</h:form>
</h:body>
</html>
response.jsp
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
<h:head>
<title>Guess Number Facelets Application</title>
</h:head>
<h:body>
<h:form>
<h2>
<h:outputText id="result" value="#{resultNumber.response}"/>
</h2>
<h:commandButton id="back" value="Back" action="greeting.xhtml"/>
</h:form>
</h:body>
</html>
Java bean, ResultNumber.java
package guessNumber;
import java.util.Random;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
/**
* Session Bean implementation class ResultNumber
*/
#Stateless(mappedName = "resultNumber")
#LocalBean
public class ResultNumber {
Integer randomInt = null;
Integer userNumber = null;
String response = null;
private long maximum=10;
private long minimum=0;
public ResultNumber() {
Random randomGR = new Random();
randomInt = new Integer(randomGR.nextInt(10));
System.out.println("Duke's number: " + randomInt);
}
public void setUserNumber(Integer user_number) {
userNumber = user_number;
}
public Integer getUserNumber() {
return userNumber;
}
public String getResponse() {
if ((userNumber != null) && (userNumber.compareTo(randomInt) == 0)) {
return "Yay! You got it!";
} else {
return "Sorry, " + userNumber + " is incorrect.";
}
}
public long getMaximum() {
return (this.maximum);
}
public void setMaximum(long maximum) {
this.maximum = maximum;
}
public long getMinimum() {
return (this.minimum);
}
public void setMinimum(long minimum) {
this.minimum = minimum;
}
}
Now for the configuration files
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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>SimpleJSF</display-name>
<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>
<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>client</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>
<welcome-file-list>
<welcome-file>faces/greeting.jsp</welcome-file>
</welcome-file-list>
</web-app>
facet-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>resultNumber</managed-bean-name>
<managed-bean-class>guessNumber.ResultNumber</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
In JSF 2.0, JSP is been deprecated as view technology and succeeded by Facelets. You need to rename your .jsp files to .xhtml files. In your case you also need to remove the entire <%# page %> line in both JSPs. Then you need to invoke them with the .xhtml extension in the URL.
Further, you also need to remove the ConfigureListener from web.xml and you need to rename the JSP welcome file to XHTML. I'd also suggest to use *.xhtml instead of /faces/* as FacesServlet URL pattern. This way you don't need to put a /faces/* in URLs everytime. Finally you need to remove the bean from faces-config.xml and annotate the bean as follows instead of those javax.ejb annotations:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
#ManagedBean
#RequestScoped
public class ResultNumber {
After all, it seems that you were reading JSF 1.x tutorials and mixing it up with JSF 2.x. You should be extremely careful what JSF version the JSF book/tutorial you're reading target. Since JSF 2.0 a lot of things are done differently.
You are using .jsp files,so you should import the taglibs manually.Add these two lines right above your opening html tag.
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>