Below is part of code !!! i am new to jsp !!! it is giving error at variable temp1... help me out

try
		{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			String url="jdbc:mysql://localhost/ecops";
			Connection con = DriverManager.getConnection(url,"root","");
			java.sql.Statement stmt = con.createStatement();
			ResultSet rs=stmt.executeQuery("Select max(cid) from citizen_info");
			while(rs.next()){
			
			int temp1=rs.getInt("max(cid)");
			break;
			}
			
			   temp1=temp1++;
			  stmt.executeUpdate("insert into citizen_info values("+temp1+",'"+uname+"','"+pass+"','"+addr+"',"+age+",'"+date1+"','"+gender+"','"+qualif+"','"+mob+"','"+email+"','"+proof+"')");
			  stmt.executeUpdate("insert into login values("+appln+",'"+uname+"','"+pass+"','"+email+"')");
			  out.println("You are successfully registered ");
			
			
			con.close();
		}
		catch(Exception e)
		{
		out.println("Error "+e);
		}

First of all: Delete the entire code. Never do that again. That code needs to be in a separate class. Create such a class and put the code that connects to the database and does whatever you want in a method and call that method. That method should return(true/false) whether the operation was successful or not in order to print the message.

Second and most important. Stop writing jsps. The error that you get has nothing to do with jsps. When someone starts writing jsps, it is supposed, that they know java. They know the basics of java. The error that you get is not about jsps, so even if you are new to jsps you should be able to fix it, just by reading the error messages of the compiler.
It is a basic beginner's error that anyone that starts writing jsps must be able to fix it.
You should be writing more exercises and studying more basic java.
You don't even close anything in your code! You should be closing the Connection, Statement and ResultSet in the finally block not only the Connection in the try

The above is an advice. Not to be taken personally. You should know more things than you already know before going and writing such code. Even in core java you should be using classes and put code in methods so you can call it elsewhere instead of putting the entire code in the main method (in your case in the jsp).

If you want to insist with jsps then put the above code in separate class and method and when you try to compile the class read the error message the compiler gives you. Give it a try, before posting the error message that you get.

Assuming that you have ClassA and method1:
In jsp:

<%
ClassA cl = new ClassA();
boolean b = cl.method1(uname, pass, addr, age, ......);
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.