473,414 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to fix Face context Error in JSF?

login.jsp
Expand|Select|Wrap|Line Numbers
  1. <%@ page contentType="text/html"%>
  2. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  3. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
  4. <f:view>
  5.     <html>
  6.         <head>
  7.             <title>JSF Login Application</title>
  8.         </head>
  9.         <body>
  10.             <h:form>
  11.                 <table>
  12.                     <tr>
  13.                         <td><h:outputText value="Enter Login ID: " /></td>
  14.                         <td><h:inputText id="id" value="#{LoginBean.loginid}" /></td>
  15.                     </tr>
  16.                     <tr>
  17.                         <td><h:outputText value="Enter Password: " /></td>
  18.                         <td><h:inputSecret id="pwd" value="#{LoginBean.pwd}" /></td>
  19.                     </tr>
  20.                     <tr>
  21.                         <td>&nbsp;</td>
  22.                         <td><h:commandButton value="Login" action="#{LoginBean.CheckValidUser}" /></td>
  23.                     </tr>
  24.                 </table>
  25.             </h:form>
  26.         </body>
  27.     </html>
  28. </f:view>
  29.  

loginfail.jsp

Expand|Select|Wrap|Line Numbers
  1. Login Failed. Please try again.
  2.  
loginsuccess.jsp

Expand|Select|Wrap|Line Numbers
  1. Login Successful.
  2.  
LoginBean.java
Expand|Select|Wrap|Line Numbers
  1. package javajazzup;
  2.  
  3. public class LoginBean{
  4.     String loginid;
  5.     String pwd;
  6.  
  7.     public LoginBean(){}
  8.  
  9.     public String getLoginid(){
  10.         return loginid;
  11.     }
  12.     public void setLoginid(String loginid){
  13.         this.loginid = loginid;
  14.     }
  15.     public String getPwd(){
  16.         return pwd;
  17.     }
  18.     public void setPwd(String pwd){
  19.         this.pwd = pwd;
  20.     }
  21.     public String CheckValidUser(){
  22.         if(loginid.equals("JavaJazzUp") && pwd.equals("mypwd")){
  23.             return "success";
  24.         }
  25.         else{
  26.             return "fail";
  27.         }
  28.     }
  29. }
  30.  

faces-config.xml

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <!DOCTYPE faces-config PUBLIC
  3.   "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
  4.  
  5. <faces-config>
  6.     <managed-bean>
  7.         <managed-bean-name>LoginBean</managed-bean-name>
  8.         <managed-bean-class>javajazzup.LoginBean</managed-bean-class>
  9.         <managed-bean-scope>request</managed-bean-scope>
  10.     </managed-bean>
  11.     <navigation-rule>
  12.         <from-view-id>/login.jsp</from-view-id>
  13.         <navigation-case>
  14.             <from-action>#{LoginBean.CheckValidUser}</from-action>
  15.             <from-outcome>success</from-outcome>
  16.             <to-view-id>loginsuccess.jsp</to-view-id>
  17.         </navigation-case>
  18.         <navigation-case>
  19.             <from-action>#{LoginBean.CheckValidUser}</from-action>
  20.             <from-outcome>fail</from-outcome>
  21.             <to-view-id>loginfail.jsp</to-view-id>
  22.         </navigation-case>
  23.     </navigation-rule>
  24. </faces-config>
  25.  

web.xml

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  3. "http://java.sun.com/dtd/web-app_2_3.dtd">
  4.  
  5. <web-app>
  6.     <context-param>
  7.         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  8.         <param-value>server</param-value>
  9.     </context-param>
  10.  
  11.     <!-- Faces Servlet -->
  12.     <servlet>
  13.         <servlet-name>Faces Servlet</servlet-name>       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  14.         <load-on-startup> 1 </load-on-startup>
  15.     </servlet>
  16.  
  17.     <!-- Faces Servlet Mapping -->
  18.     <servlet-mapping>
  19.         <servlet-name>Faces Servlet</servlet-name>
  20.         <url-pattern>*.jsf</url-pattern>
  21.     </servlet-mapping>
  22. </web-app>
  23.  

after compiling java code
i run this application but i got Face context Error
Please help me out

error




HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:500)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:428)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)

root cause

java.lang.RuntimeException: Cannot find FacesContext
javax.faces.webapp.UIComponentClassicTagBase.getFa cesContext(UIComponentClassicTagBase.java:1797)
javax.faces.webapp.UIComponentClassicTagBase.setJs pId(UIComponentClassicTagBase.java:1614)
org.apache.jsp.login_jsp._jspx_meth_f_005fview_005 f0(login_jsp.java:98)
org.apache.jsp.login_jsp._jspService(login_jsp.jav a:75)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
Feb 25 '11 #1
0 1600

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Bowling | last post by:
I'm trying to get the day of month with: int dayofmonth; dayofmonth = Calendar.get(Calendar.DAY_OF_MONTH); and I get the compile time error of saying get(int) is a not-static method. Is...
0
by: Yannick Turgeon | last post by:
Hello all, Back-end: SS2000 SP2 + NT4 Front-end: A97 + XP We are currently trying to add a Domain Server to our network. We added our SQL Server to the domain and added a client too....
4
by: Denise | last post by:
I am trying to implement database error logging in my asp.net application. When I inspect the exception variable, I see that there is a property called 'procedure' which I believe is the procedure...
0
by: SunSmile | last post by:
Hi, I am getting the following error when i try to throw an exception. The exception i throw is caught up in the hierarchy and is rethrown and so on. This error is only coming up when unit...
1
by: kingski | last post by:
I have a web page (Asp.net 2.0, vs2005) in which there is this construction: <img src="/pages/showimage.aspx"> In global.asax I access sessions in Application_PreRequestHandlerExecute event. ...
4
by: Rick | last post by:
I've moved code from a stage machine to the production machine, exact same code works fine on the stage machine, they are both windows 2003 servers, I'm getting a "Cannot generate SSPI context"...
4
by: jclover | last post by:
I have an excel spreadsheet that is linked to a query in an access database on a shared network drive. There is no security in the database, or the spreadsheet. As of this weekend, the other users...
2
by: maniishkumar | last post by:
I am writing a string as Response.Write("Hello world"); on Page_UnLoad() event. I am using ASP.NET with C#. When I execute this error and run the application I found this error that Response...
0
by: Dave | last post by:
I have an ASPX page that I can't seem to do anything with the dropdowns. The error that I'm getting is "The name 'EmployeeDropdownList' does not exist in the current context. I have all the...
1
by: vasanth chandrasekaran | last post by:
The error is :Syntax error in INSERT INTO statement. This is my code: try { DataSet ds1; OleDbConnection ConnSql; OleDbConnection...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.