Java Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 306
Number of posts: 629

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
HELP.. LOGIN IN JSP USING MYSQLYOG Posted by pixlucas on 29 Sept 2009 at 11:23 PM
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>




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.