I believe this is strictly a Java syntax question, but I'm having a problem displaying a String. It's basically setup like this:
I'm assuming this is because the string "id" is inside the while statement, but what would be the best way to get it to display in the body tag? Thanks
Code:
<html>
<head>
<%
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb);
Statement stmt = myConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT petid FROM pettable");
while(rs.next()){
String id = rs.getString("petid");
}
con.close();
%>
</head>
<body>
<%= id %>
</body>
</html>
I'm assuming this is because the string "id" is inside the while statement, but what would be the best way to get it to display in the body tag? Thanks