I get an error on the jsps when I try to run the index that forwards to the jsps that connects to the database, and the database name and everything is fine.
the error it gives me is
HTTP Status 500 – Internal Server Error
org.apache.jasper.JasperException: An exception occurred processing [/registration.jsp] at line [25]
22: //it returns com.mysql.jdbc.Driver.class.
23:
24:
25: java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employeeexample", "root","1234");
26: Statement stmt = conn.createStatement();
27:
28: // stmt.executeUpdate("insert into users2(user_id,password,fname,lname,email)" +"values"+"("+user+"','"+pwd+ "','"+fname+"','"+lname+",'"+email+"')");
IT GIVES ME THE SAME ERROR ON THE LOGIN.JSP BUT INSTEAD THE LINE NUMBER THAT DIRECTLY CORRESPONDS WITH THE CONNECTION.
LOGIN.JSP
REGISTRATION.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration.jsp</title>
</head>
<body>
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<%
String user = request.getParameter("user");
//session.putValue("userid",user);
String pwd = request.getParameter("pwd");
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String email= request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
//it returns com.mysql.jdbc.Driver.class.
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employeeexample", "root","1234");
Statement stmt = conn.createStatement();
// stmt.executeUpdate("insert into users2(user_id,password,fname,lname,email)" +"values"+"("+user+"','"+pwd+ "','"+fname+"','"+lname+",'"+email+"')");
stmt.executeUpdate
("insert into users2 values"+"('"+user+"','"+pwd+"','"+fname+"','"+lname+"','"+email+"')");
// stmt.executeUpdate("insert into users2(user_id,password) " + "values ('"+user+"','"+pwd+"')");
//stmt.executeUpdate("insert into users values("+pwd+ "','"+fname+"','"+lname+",'"+email+"')");
ResultSet rs = stmt.executeQuery ("SELECT * FROM users2 WHERE user_id ='"+ user + "'");
if(rs.next())
{
out.println("welcome "+user);
}
out.println(user+ " Registered");
%>
<a href = "Login.html"> Login</a>
<a href = "Registration.html"> Registration</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<%
String user = request.getParameter("user");
//session.putValue("user",user);
String pwd = request.getParameter("pwd");
Class.forName("com.mysql.jdbc.Driver");
//it returns com.mysql.jdbc.Driver.class.
java.sql.Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/employeeexample", "root","1234");
Statement stmt = conn.createStatement();
String query = "SELECT * FROM users2 WHERE user_id ='"+ user + "'";
out.println("Query: "+query);
ResultSet rs = stmt.executeQuery (query);
out.println("<br/><br/>Results");
while(rs.next()){
String s = rs.getString("user_id");
out.println("<br/><br/>\t\t"+s);
}
/*
if(rs.next())
{
if(rs.getString(2).equals(pwd)){
out.println("welcome "+user);
out.println("SELECT * FROM users2 WHERE user_id ='"+ user + "'");
}
else{
out.println("WRONG PW!!! TRY AGAIN");
}
}
*/
%>
<a href ="index.html"> Home </a>
</body>
</html>