J 1
J 1
J 1
IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
private static final String JDBC_URL =
"jdbc:mysql://your_database_host:your_database_port/your_database
_name";
private static final String JDBC_USER =
"your_database_username";
private static final String JDBC_PASSWORD =
"your_database_password";
int rowsAffected =
preparedStatement.executeUpdate();
if (rowsAffected > 0) {
out.println("Registration successful!<br>");
out.println("Username: " + username + "<br>");
out.println("Password: " + password + "<br>");
} else {
out.println("Registration failed. Please try
again.<br>");
}
}
} catch (SQLException e) {
e.printStackTrace();
out.println("Error: " + e.getMessage());
}
}
}