I have been making registration page using the code I once used in my project that worked 100% correctly, however I am getting errors this time. I have added all libraries and jars
Still I keep getting errors like
<%@ 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>CodeGyan - Learn Programming Online</title>
<link rel="icon" href="images/logo.png" type="image/x-icon">
</head>
<body>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%
String firstname=request.getParameter("firstname");
String lastname=request.getParameter("lastname");
String username=request.getParameter("username");
session.putValue("username",username);
String pwd=request.getParameter("pwd");
String email_id=request.getParameter("email_id");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/codegyan", "CinthiyaSingh", "Cinthiya@098");
//selecting username from users table
PreparedStatement ps = con.prepareStatement("select *from users where username=?");
ps.setString(1, username);
ResultSet rs = ps.executeQuery();
PreparedStatement ps1 = con.prepareStatement("select *from users where email_id=?");
ps1.setString(1, email_id);
ResultSet rs1 = ps1.executeQuery();
//if true
if (rs.next()) {
//sending error message on Register page
request.getSession().setAttribute("errorMessage", "Already Existing Username, Please Try Again With a Unique Username! ");
request.getRequestDispatcher("register.jsp").forward(request, response);
}
else if(rs1.next()){
request.getSession().setAttribute("errorMessage", "Already Existing Email, Please Try Again With Valid Email-ID! ");
request.getRequestDispatcher("register.jsp").forward(request, response);
}
else {
//If not exist performing insert
PreparedStatement ps2 = con.prepareStatement("insert into users values(?,?,?,?,?)");
//setting value for "?"
ps2.setString(1, username);
ps2.setString(2, pwd);
ps2.setString(3, firstname);
ps2.setString(4, lastname);
ps2.setString(5, email_id);
int i = ps2.executeUpdate();
//if updated successfully
if (i > 0) {
//redirect
request.getSession().setAttribute("errorMessage", "Registered Successfully! Please Login to Fill The Form ");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
//close connection
con.close();
}
%>
</body>
</html>
I have a page (jsp) page where I have the form. The name of that page is Register.jsp. I have followed the method of build path to add jars still nothing changed.