Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/12/2007, 14:47
Onuris
 
Fecha de Ingreso: diciembre-2007
Mensajes: 36
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: Error al intentar acceder a un metodo en un archivo .java desde uno .jsp

Asi esta mi dynamic web proyect:

validarUsuario.jsp
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language = "java" cotentType = "text/xml; charset = utf-8" page ecoding = "utf-8" import = "com.mercosur.accesoabase.AccesoABase"%>
<%
	boolean mostrarFormulario = false;
	boolean mostrarError = false;
	String nombre = null;
	boolean existe = false;

	if (request.getParameter("usuario") == null) {
		mostrarFormulario = true;
	} else {
		String usr = request.getParameter("usuario");
		String psw = request.getParameter("password");

		AccesoABase  acceso = new AccesoABase();
		existe = acceso.buscarElUsuarioYLaPass( usr, psw);
		if (existe) {
			mostrarFormulario = false;
			mostrarError = false;
			nombre=usr;
		} else {
			mostrarFormulario = true;
			mostrarError = true;
		}
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Loguin de usuario</title>
</head>
<body>
<%
if (mostrarFormulario) {
%>
	<form name="Login" method="post" action="validarUsuario.jsp">
		<input type="text" name="usuario">
		<input type="password" name="password">
		<input type="submit" name="Ingr esar">
	</form>
	<%
	if (mostrarError) {
	%>
		<h1>El nombre de usuario o la clave son invalidos</h1>
		<%
			}
			} else {
		%>
	<h1>Bievenido <%=nombre%></h1>
	<%
	}
	%>
</body>
</html>
AccesoABase.java
Código:
package com.mercosur.accesoabase;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AccesoABase {
    public boolean buscarElUsuarioYLaPass(String usuarioid, String password)throws SQLException{
        Connection coneccion = null;
        PreparedStatement statement = null;
        ResultSet resultset = null;
       
        String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
        String URL = "jdbc:derby:e:\\Usuarios";
        String QUERY = "SELECT * FROM USUARIOS.LOGIN WHERE USUARIOID=? AND PASSWORD=?";
       
        boolean existe = false;
       
        try {
            Class.forName(DRIVER);
            coneccion = DriverManager.getConnection(URL);
            statement = coneccion.prepareStatement (QUERY);
            statement.setString( 1, usuarioid);
            statement.setString( 2, password);
            resultset = statement.executeQuery(QUERY);
            if (resultset.next())
                existe = true;
        } catch (Exception e) {
                e.printStackTrace();
        } finally {
        	if (resultset != null)
        		resultset.close();
            if (statement != null)
                statement.close();
            if (coneccion != null)
                coneccion.close();
        }
        return existe;
    }
}
El tema es que cuando corro el jsp me tira un error http:500, a veces al actualizar el ffox me muestra el formulario, pero tira error de nuevo al actualizar, o apretar el boton, no me deja hacer nada de nada, supuestamente esta todo bien, porque me falla???