Create login screen in xhtml with BD

0

I'm doing an academic job and I'm stuck for not doing it.

At first I need to create a login screen in the index and with this consult the DB and check the user and with this move to the next page _.

I'm using NetBeans 8.2, there we created a web project, and we connected the DB with glassfish 4.1.1 and we used the hibernate and JavaServes faces. I create a Unit of persistence and pull the elements of DB ...

Good explanation and let's go to the code.

I did this in Index:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
        <h:outputStylesheet name="css/jsfcrud.css"/>
    </h:head>
    <h:body>
        <div align="center">Welcome!!</div>

        <form name="login" method="post" action="login.jsp">
            <div align="center">
                Usuário: <input type="text" name ="nome"></input> </div>
            <div align="center">
                Senha: <input type="password" name="senha"></input> </div>
            <div align="center"> 
            <input type="submit" value="Acessar"></input>
            <input type="reset" value="Limpar"></input>
            </div>
        </form>
            <br />
            <h:link outcome="/tblcliente/List" value="Show All Tblcliente Items"/>
            <br />
            <h:link outcome="/tbldistribuidora/List" value="Show All Tbldistribuidora Items"/>
            <br />
            <h:link outcome="/tblfunc/List" value="Show All Tblfunc Items"/>
            <br />
            <h:link outcome="/tblmateriaprima/List" value="Show All Tblmateriaprima Items"/>
            <br />
            <h:link outcome="/tbltransportadora/List" value="Show All Tbltransportadora Items"/>             
    </h:body>
</html>

The login form already has, I just do not know how to get the infos and pass to BD ...

My Model imported from DB and became a class.

@Entity
@Table(name = "tblusuario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tblusuario.findAll", query = "SELECT t FROM Tblusuario t")
    , @NamedQuery(name = "Tblusuario.findByIdtblusuario", query = "SELECT t FROM Tblusuario t WHERE t.idtblusuario = :idtblusuario")
    , @NamedQuery(name = "Tblusuario.findByNomeusuario", query = "SELECT t FROM Tblusuario t WHERE t.nomeusuario = :nomeusuario")
    , @NamedQuery(name = "Tblusuario.findBySenha", query = "SELECT t FROM Tblusuario t WHERE t.senha = :senha")})
public class Tblusuario implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idtblusuario")
    private Integer idtblusuario;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nomeusuario")
    private String nomeusuario;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "senha")
    private String senha;
    
asked by anonymous 20.04.2018 / 16:02

0 answers