I would like to know how I can pass the value of a variable from a java class to a jsp.
public void ValidateUser (String user, String password, HttpServletRequest request) {
try {
Connection conexion=null;
PreparedStatement pst = null;
ResultSet rs = null;
conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/ticketsdetrabajo", "root", "123456");
//creamos objeto Statement
pst=conexion.prepareStatement(sql);
pst.setString(1, usuario);
pst.setString(2, password);
rs=pst.executeQuery();
if(rs.next())
{
dbUsuario=rs.getString("NombreUsuarios");
dbPass=rs.getString("Contrasena");
if(dbUsuario.equals(usuario)&& dbPass.equals(password)) {
HttpSession sesion = request.getSession();
login=true;
}
}else {
System.out.print("El usuario o Contraseña introducidos son erroneos");
login=false;
}
I would like to pass the login variable to a jsp page to redirect to the page only if it is correctly registered: