esse é o meu jsp
[code]<%@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”%>
<!--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>
[/code]
esse é meu faces-config
[code]<?xml version='1.0' encoding='UTF-8'?>
/login.jsp ok /index.jsp erro /login.jsp MBLogin com.metaway.beans.MBLogin session [/code]meu managed bean
/*
* 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
[code]/*
- 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;
}
}
[/code]
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