<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<f:view>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h:form id="login_form">
<h:panelGrid columns="2" id="login_panel">
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<f:facet name="footer">
<h:commandButton value="Logar" action="login"/>
</f:facet>
<!--campo usuario-->
<h:outputLabel for="usuario">
<h:outputText value="Usuario"/>
</h:outputLabel>
<h:inputText value="#{MBLogin.LO.usuario}" id="usuario" />
<!--campo senha-->
<h:outputLabel for="senha">
<h:outputText value="Senha"/>
</h:outputLabel>
<h:inputSecret value="#{MBLogin.LO.password}" id="senha" />
</h:panelGrid>
</h:form>
</body>
</f:view>
</html>
esse é meu faces-config
<?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">
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<faces-config>
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>ok</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>erro</from-outcome>
<to-view-id>/login.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>MBLogin</managed-bean-name>
<managed-bean-class>com.metaway.beans.MBLogin</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
/*
* ControleLogin.java
*
* Created on 16 de Janeiro de 2009, 13:28
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.metaway.beans;
import com.metaway.dao.LoginDAO;
import com.metaway.pojo.login;
/**
*
* @author Mtw3
*/
public class MBLogin{
private LoginDAO loginDAO= new LoginDAO();
private login LO;
/** Creates a new instance of ControleLogin */
public MBLogin() {
}
//pojo-----------------
public login getLO() {
return LO;
}
public void setLO(login LO) {
this.LO = LO;
}
//------------------pojo
public String login(){
System.out.println("usuario= "+LO.getUsuario());
System.out.println("password= "+LO.getPassword());
boolean ok = loginDAO.Login(LO.getUsuario(),LO.getPassword());
if(ok==true){
return "ok";
}else return "erro";
}
}
meu pojo
/*
* login.java
*
* Created on 16 de Janeiro de 2009, 13:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.metaway.pojo;
import java.io.Serializable;
public class login {
private String usuario;
private String password;
public login() {
}
public login(String usuario, String password){
this.setUsuario(usuario);
this.setPassword(password);
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
e meu dao
/*
* LoginDAO.java
*
* Created on 16 de Janeiro de 2009, 13:35
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.metaway.dao;
import com.metaway.bd.Conexao;
import java.sql.*;
/**
*
* @author Mtw3
*/
public class LoginDAO {
/** Creates a new instance of LoginDAO */
public LoginDAO() {
}
public boolean Login(String usuario, String password){
boolean ok=false;
try {
String sql = "select * from usuario where usuario = ?";
Connection c = Conexao.getConnection();
PreparedStatement pstm = c.prepareStatement(sql);
pstm.setString(1,usuario);
ResultSet rs = pstm.executeQuery();
if(!rs.getString("usuario").equals(null)){
if(rs.getString("usuario").equals(usuario)){
ok=true;
}
}else{
ok=false;
}
} catch (SQLException ex) {
ex.printStackTrace();
}
return ok;
}
}
o objetivo é simples, dgita-se o username e a senha, e verfica-se oq foi digitado com oq esta no banco....
qnd clico no botao logar ganho esse erro ...
javax.servlet.ServletException: Error testing property 'usuario' in bean of type null

