I am working on a small test where I made a table of data in mysql and use hibernate to generate the pojo, the ingnieria inverse and the config file of hibernate cfg in xml. I made a small form in html to try to enter the data and store it in the database, but I am still very new in this and I do not know how to communicate html with java, I would greatly appreciate your help.
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="PersonalInf.java" method="post">
<input type="text" name="id" placeholder="Id" >
<input type="text" name="nombre" placeholder="Nombre" >
<input type="text" name="apellido" placeholder="Apellido">
<input type="text" name="sexo" placeholder="Sexo">
<input type="number" name="edad" placeholder="Edad">
<button type="submit">Enviar</button>
</form>
</body>
</html>
and here I leave the hibernate code:
/*
* 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.
*/
package Controlador;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import Modelo.*;
/**
*
* @author Aldo
*/
public class Funcion {
public void altaUsuarios(PersonalInf user){
SessionFactory sesion= NewHibernateUtil.getSessionFactory();
Session session;
session=sesion.openSession();
Transaction tx=session.beginTransaction();
session.save (user);
tx.commit();
session.close();
JOptionPane.showMessageDialog(null, "Insertado correctamente");
}
}