2 Replies Latest reply on Aug 9, 2006 1:03 AM by Tahir Akram

    javax.servlet.ServletException: Cannot get value for express

    Tahir Akram Newbie

      I m having problem with running of my JSP page which is calling managed bean properties. I dont know wht thing is missing but I hope with review of u ppl I will got the solution..

      convert.jsp:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <html>
      <head>
      </head>
      <body>
      <f:view>
       <html>
       <head>
       <title>Celsius converter</title>
       </head>
       <body>
       <h1>Celcius Convertersss</h1>
       <hr>
       <h:form>
       <h:inputText value="#{pageBean.celsius}" />
       <h:outputText value="Celsius" /><br/>
       <h:outputText value="#{pageBean.fahrenheit}" />
       <h:outputText value="Fahrenheit" /><br/>
       <h:commandButton value="Convert" action="#{pageBean.convertToFahrenheit}" />
      
       </h:form>
       </body>
       </html>
      </f:view>
      
      </body>
      </html>


      faces-config.xml:

      <?xml version="1.0"?>
      <!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>
       <!--Now this config file is empty-->
      
      
       <managed-bean>
       <managed-bean-name>pageBean</managed-bean-name>
       <managed-bean-class>jsfbean.PageBean</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       </managed-bean>
      
      </faces-config>
      


      PageBean:

      package jsfbean;
      
      public class PageBean {
       private Double celsius = null;
       private Double fahrenheit = null;
      
       public PageBean(){
       }
      
       public void setCelsius(Double celsius){
       this.celsius = celsius;
       }
      
       public Double getCelsius(){
       return celsius;
       }
      
       public void setFahrenheit(Double fahrenheit){
       this.fahrenheit = fahrenheit;
       }
      
       public Double getFahrenheit(){
       return fahrenheit;
       }
      
       public void convertToFahrenheit(){
       setFahrenheit(new Double(getCelsius().doubleValue() * 1.8 + 32));
       }
      }
      


      web.xml:

      <?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>
       <display-name>The simplest JSF application.</display-name>
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
       </servlet-mapping>
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      </web-app>
      


      Please share if u have solve this problem....

      Thx

        • 1. Re: javax.servlet.ServletException: Cannot get value for exp
          Tahir Akram Newbie

          here is the exceptions I m faciong

          exception
          
          javax.servlet.ServletException: Cannot get value for expression '#{pageBean.celsius}'
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          
          
          root cause
          
          javax.faces.FacesException: Cannot get value for expression '#{pageBean.celsius}'
           org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
           org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
           org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          
          


          • 2. Re: javax.servlet.ServletException: Cannot get value for exp
            Tahir Akram Newbie

            The issue is resolved...

            The main problem was my class was not recognized by my managed bean. But that was my syupidity, bcoz I was packagaing my ..class directly in WEB-INF/classes/.class

            I was not including my package with my class while packaging.

            so thx all of u who think 2 reply

            - Tahir