• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EL expressions are not evaluated

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

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" />,
<h:outputText 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 UserNameBean.java file

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 is just printing it
same happens at welcome.jsf
i get Welcome, #{UserBean.userName} to JSF 1.2 World!

what am i doing wrong
Please help
Krishan
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RoseIndia isn't what it used to be.

First off, don't name beans with an uppercase first letter. Names starting in uppercase should be class names, names starting in lowercase are instance names. JSF will start to give you problems with that once you move to JSF2.

From the looks of it, you're mistaking the filename for the URL. If you request the page as "inputname.jsp", the URL parser won't route the request to the FacesServlet and the EL won't be evaluated. The tags shouldn't work, either, but HTML ignores tags it doesn't understand, so you generally wouldn't see anything wrong there.

To route the request to the FacesServlet, your URL should be either "faces/inputname.jsp" or "inputname.jsf". Which URL form you use depends on what URL matching pattern for FacesServlet is defined in your web.xml file.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic