THE ERROR:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 21 in the jsp file: /registration.jsp
Duplicate local variable rs
18: Class.forName("com.mysql.jdbc.Driver");
19: Connection con =DriverManager.getConnection ("jdbc:mysql://localhost:8080/dbstudent", "root", "");
20: Statement stmt = con.createStatement();
21: ResultSet rs = stmt.executeQuery("Select * from tbladmin where user='" + user + "'");
22: while(rs.next())
23: {
24: if(pass.equals(rs.getString("pass")))
MY CODE:
<%@ page import="java.sql.*,java.io.*" %>
<html>
<head>
<title>Registration</title>
</head>
<body>
<%
String user = request.getParameter("username");
String pass = request.getParameter("pass");
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con =DriverManager.getConnection ("jdbc:mysql://localhost/dbstudent", "root", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from tbladmin where user='" + user + "'");
while(rs.next())
{
if(pass.equals(rs.getString("pass")))
{
%>
Registration<br>
<form action="../glenenaje/confirm.jsp" method=post>
Student No: <input type=text name=studno><br>
Name: <input type=text name=studname><br>
Gender:<br>
<input type=radio name=gender value=Male>Male<br>
<input type=radio name=gender value=Female>Female<br>
Course: <input type=text name=course value=DCET><br>
<input type=submit value=Register><br>
</form>
<%
}
else
out.println("Incorrect Password");
}
rs.close();
stmt.close();
con.close();
}
catch (SQLException e)
{
throw new ServletException("Servlet Could not display records.", e);
}
%>
</body>
</html>