<%@ page import="java.sql.*" %> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Username Check</title> </head> <body> <% String username = request.getParameter("name"); String jdbcUrl = "jdbc:mysql://localhost:3306/nehal"; String dbUser = "root"; String dbPassword = "nehal@123"; Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { Class.forName("com.mysql.cj.jdbc.Driver"); conn = DriverManager.getConnection(jdbcUrl, dbUser, dbPassword); String sql = "SELECT * FROM emp WHERE name = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, username); rs = pstmt.executeQuery(); if (rs.next()) { out.println("<h2>Success: Username '" + username + "' exists in the database.</h2>"); } else { out.println("<h2>Failure: Username '" + username + "' does not exist.</h2>"); } } catch (Exception e) { out.println("<h2>Error: " + e.getMessage() + "</h2>"); } finally { try { if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); } catch (SQLException e) { } } %> </body> </html> --html <!DOCTYPE html> <html> <head> <title>Update User</title> </head> <body> <h2>Update User Information</h2> <form action="updateUser.jsp" method="post"> <label for="id">User ID:</label> <input type="text" id="id" name="id" required><br><br> <label for="name">New Name:</label> <input type="text" id="name" name="name" required><br><br> <input type="submit" value="Update"> </form> </body> </html>