Thank for responding. In an effort to shorten the
question and answer cycle before it discourages you from helping, I'm
including pretty much the whole source here. I'm not at home where I'm
doing this, but to answer your first question directly, here are the
guts of web.xml:
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
which I copied from Geary & Horstmann's first chapter. I also tried
index.jsp as the welcome file, but entering index.html into the browser
which contains
<html>
<head>
<meta http-equiv="Refresh" content= "0; URL=index.faces"/>
<title>Start Web Application</title>
</head>
<body>
<p>Please wait for the web application to start.</p>
</body>
</html>
and works fine, so I kept it as they suggest. I am a little confused
with the .faces vs. .jsp thing. I read that explanation several times
in the book and still don't get it, but I've chaulked it up to more
web.xml hocus-pocus that I'll probably catch onto after I've gained a
little more experience.
It's my JSP that doesn't work and gives the error whose summary I
reported. Here are the guts of my index.jsp:
<f:view>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>A Simple JavaServer Faces
Application</title>
</head>
<body>
<h:form>
<h3>Please enter your name and password.</h3>
<table>
<tr>
<td>Name:</td>
<td><h:inputText
value="#{user.name}"/></td>
</tr>
<tr>
<td>Password:</td>
<td><h:inputSecret
value="#{user.password}"/></td>
</tr>
</table>
<p><h:commandButton value="Login"
action="#{user.login}"/> </p>
</h:form>
</body>
</html>
</f:view>
and, just so you don't have to ask for it, the bean code is
package com.corejsf;
public class UserBean
{
private String name;
private String password;
public String getName() { return name; }
public void setName(String newValue) { name = newValue; }
public String getPassword() { return password; }
public void setPassword(String newValue) { password = newValue; }
public String login() { return "login"; }
}
and faces-config.xml is (guts only):
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>com.corejsf.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
As I alluded, I tried the GUI JSF sample from the NetBeans site and it
worked fine. This time, I'm trying to type in (or get from the book
source code) some code that was written and demonstrated outside of a
GUI. In the book, Geary & Hortstmann compile directly with Java and
then use GlassFish. I'm trying to use their code in NetBeans and
Tomcat. I did this by setting up a normal JSF project, but then
deleting the default Page1, Page2, etc. and adding my own files
(index.html, index.jsp) plus the guts to web.xml and faces-config.xml.
I'm in essence "growing" the Geary & Horstmann by-hand stuff into
the NetBeans "we're doing all this cool stuff for you, but it will make
it hard for you to figure out how to do it more by hand" GUI.
I'm in fact a refugee from Eclipse--challenged by a friend to try out
NetBeans as a solution to the difficulty of doing JSF in that
environment. So far, I'm way impressed, but I need to feel the
connection between the lower-level theory and higher-level practices of
NetBeans.
Thanks for any help you can give.
Russ
Wendy Bossons wrote:
How is your faces servlet configured?
<servlet> ....
<servlet-name>Faces Servlet ....
....
</servlet>
<servlet-mapping> .....
.....
</servlet-mapping>
..\W
Russell Bateman wrote:
I'm trying to put together Core JavaServer Faces'
login example from chapter 1, but I get an HTTP 500 error once I reach
my index.jsp:
exception
org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext
.
.
.
root cause
java.lang.RuntimeException: Cannot find FacesContext
javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1811)
javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1628)
org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:94)
I have done the NetBeans tutorial on JSF and it works. Only, I'm trying
to grow the concepts (nitty-gritty JSF) from Geary/Horstmann up to
NetBeans. In NetBeans 6.1, lots of work is done behind the scenes, but
if I grok something at the low level, I don't always know how to relate
(or do) it at the Visual Web JSF level. I'm thinking once I've gone
from the bottom up after having gone from the top down, some important
notions might begin to click.
The login example at netbeans.org is for version 5.5 and much has
changed since then (or so it appears to me) and that tutorial didn't
get me very far.
I hope someone has a good suggestion.
Russ
--
..\Wendy
Wendy Bossons
Senior User Interface Developer
Harvard-MIT Data Center
Office Phone: 617-384-5701
Email: wbossons <at> hmdc.harvard.edu