<%@ taglib uri="http://java.su...">

EL expressions are not evaluated

My inputname.jsp file

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head> <title>enter your name page</title> </head> <body> <f:view> <h1> <h: outputText value="JSF 1.2 Tutorial"/> </h1> <h:form id="UserEntryForm"> <h: outputText value="Enter Your Name:"/> <h:inputText value="#{UserBean.userName}" /> <h:commandButton action="welcome" value="OK" /> </h:form> </f:view> </body> </html> My welcome.jsp file <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head> <title>Welcome</title> </head> <body> <f:view> <h3> <h: outputText value="Welcome" />, <hutputText value="#{UserBean.userName}" /> to JSF 1.2 World! </h3> </f:view> </body> </html> 

my web.xml file

 <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-- 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> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> </web-app> 

my faces-config file

 <?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> <navigation-rule> <from-view-id>/user/inputname.jsp</from-view-id> <navigation-case> <from-outcome>welcome</from-outcome> <to-view-id>/user/welcome.jsp</to-view-id> </navigation-case> </navigation-rule> <managed-bean> <managed-bean-name>UserBean</managed-bean-name> <managed-bean-class>net.roseindia.UserNameBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> </faces-config> 

my file is UserNameBean.java

 package net.roseindia; public class UserNameBean { String userName; /** * @return User Name */ public String getUserName() { return userName; } /** * @param User Name */ public void setUserName(String name) { userName = name; } } 

when i open inputname.jsf i get

 Enter your name: #{UserBean.userName} 

instead of evaluating userbean.username, it just prints the same thing on welcome.jsf I get Welcome, # {UserBean.userName} in JSF 1.2 World!

what am i doing wrong please help Krishan

+1
source share
2 answers

Using JSF 1.2 on the JSP requires a minimum Servlet 2.5 container due to changes in EL (EL was migrated from JSF 1.1 to JSP 2.1, which is part of Servlet 2.5). You need to make sure that you are using the JSF 1.2 web application in a Servlet 2.5 compatible container with a declared web.xml that meets the Servlet 2.5 specification (or better, whatever your container supports). Your web.xml declared as Servlet 2.3, which implies a different version of EL, and therefore EL expressions will not be evaluated.

 <?xml version="1.0" encoding="UTF-8"?> <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"> <!-- Config here. --> </web-app> 

Note that your faces-config.xml not correctly declared as JSF 1.1. You want to reuse it as JSF 1.2 to take full advantage of JSF 1.2 features.

 <?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"> <!-- Config here. --> </faces-config> 

Last but not least, Roseindia.net is one of the WORST training resources for Java EE . You must put this site on your blacklist. Look for another learning resource. Although JSF 2.0 is targeted, I would suggest this tutorial and Mkyong.com resources.

+3
source

Add the correct version to your web.xml

 <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_4.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd" id="WebApp_ID" version="2.4"> 
0
source

All Articles