Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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>Examen Práctico TSIR</title>
- <h:outputStylesheet name="css/jsfcrud.css"/>
- </h:head>
- <h:body>
- <h1>Agenda Online Counselors</h1>
- <h2>Raul Llopis -- Apartado 01</h2>
- <h:button outcome="/counselor/List" value="Consultas"/>
-
- <h:button outcome="/login" value="Aministracion"/>
- </h:body>
- </html>
- --------------login
- <?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>Examen Práctico TSIR</title>
- <h:outputStylesheet name="css/jsfcrud.css"/>
- </h:head>
- <h:body>
- <h1>Agenda Online Counselors</h1>
- <h2>Raul Llopis -- Apartado 03</h2>
- <h:panelGroup rendered="#{!login.logueado}">
- <h:form>
- <h:panelGrid columns="2">
- <h:outputText value="Usuario: " />
- <h:inputText value="#{login.email}" />
- <h:outputText value="Contraseña: " />
- <h:inputSecret value="#{login.password}" />
- </h:panelGrid>
- <h:commandButton action="#{login.loguear()}" value="Login" />
- <h:button outcome="/alta" value="Alta"/>
- </h:form>
- </h:panelGroup>
- <!--
- <br />
- <h:panelGroup rendered="#{login.logueado}" >
- <h:panelGroup rendered="#{carrito.hayFosiles() || carrito.hayMinerales()}">
- <h:outputText value="#{bundle.TotalPagar}: " /><h:outputText value="#{carrito.totalCarrito()}" />
- <br />
- <h:outputText value="#{bundle.i_nombre}" />
- <br />
- <h:inputText value="#{tienda.nombre}" required="true" requiredMessage="#{bundle.e_introducir_nombre}" />
- <br />
- <h:outputText value="#{bundle.i_apellidos}" />
- <br />
- <h:inputText value="#{tienda.apellidos}" required="true" requiredMessage="#{bundle.e_introducir_apellidos}" />
- <br />
- <h:outputText value="#{bundle.i_direccion}" />
- <br />
- <h:inputText value="#{tienda.direccion}" required="true" requiredMessage="#{bundle.e_introducir_direccion}" />
- <br />
- <h:outputText value="#{bundle.i_pais}" />
- <br />
- <h:inputText value="#{tienda.pais}" required="true" requiredMessage="#{bundle.e_introducir_pais}" />
- <br />
- <h:outputText value="#{bundle.i_tarjeta}" /><br />
- <h:inputText value="#{tienda.tarjeta}" required="true" requiredMessage="#{bundle.e_introducir_tarjeta}" />
- <br />
- <h:commandButton value="#{bundle.ContinuarPago}" action="#{tienda.facturar()}" />
- </h:panelGroup>
- </h:panelGroup>
- -->
- </h:body>
- </html>
- ------------- alta
- <?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>Examen Práctico TSIR</title>
- <h:outputStylesheet name="css/jsfcrud.css"/>
- </h:head>
- <h:body>
- <h1>Agenda Online Counselors</h1>
- <h2>Raul Llopis -- Apartado 04</h2>
- <h:form>
- First name:
- <input type="text" name="firstname"><br></br></input>
- Nick name:
- <input type="text" name="nickname"><br></br></input>
- Last name:
- <input type="text" name="lastname"><br></br></input>
- Telephone:
- <input type="text" name="telephone"><br></br></input>
- Email:
- <input type="text" name="email"><br></br></input>
- Memeber Since:
- <input type="text" name="membersince"><br></br></input>
- </h:form>
- <h:button outcome="/index" value="Add"/>
-
- <h:button outcome="/index" value="Reset"/>
- <h:button outcome="/index" value="Back"/>
- -->
- </h:body>
- </html>
- -------login controller
- package jsf;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import javax.faces.bean.ManagedBean;
- import javax.faces.bean.SessionScoped;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author lopoa_000
- */
- @ManagedBean (name = "login")
- @SessionScoped
- public class LoginController{
- boolean logueado = false;
- private String email;
- private String password;
- Connection conn = null;
- public boolean getLogueado() {
- return logueado;
- }
- public void setLogueado( boolean l) {
- this.logueado = l;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getEmail() {
- return email;
- }
- public void logout()
- {
- email = "";
- password = "";
- logueado = false;
- }
- public void loguear() {
- Statement stmt = null;
- ResultSet rs = null;
- String conexion = "jdbc:mysql://localhost:3306/tsir54?user=root&password=admin";
- String query = "SELECT * FROM usuarios WHERE email = '" + getEmail() + "' AND password = '" + getPassword() + "'";
- try {
- conn = DriverManager.getConnection(conexion);
- stmt = conn.createStatement();
- rs = stmt.executeQuery(query);
- if ( rs.first() )
- setLogueado( true );
- else
- setLogueado( false );
- } catch (SQLException ex) {
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("SQLState: " + ex.getSQLState());
- System.out.println("VendorError: " + ex.getErrorCode());
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException sqlEx) {
- } // ignore
- rs = null;
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- }
- stmt = null;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement