-4
サーブレットを使用してデータベースからHTMLページにデータを表示する方法は?Servletを使用してデータベースからHTMLページにデータを表示する方法は?
サーブレットを使用してデータベースからHTMLページにデータを表示する方法は?Servletを使用してデータベースからHTMLページにデータを表示する方法は?
これは非常にばかげた質問ですが、あなたが質問したので、私はここで答えを書いています。
JDBCを使用してデータベースからデータをフェッチし、レスポンスプリントライタを使用して表示できます。
サンプルプログラム
Connection con;
PrintWriter out = response.getWriter();
response.setContentType("text/html");
con = DriverManager.getConnection("jdbc:mysql://localhost:" + "3306" + "/" + "pinnnacledb1", "root", "");
String query = "Select * from table where something = ?";
PreparedStatement pst = currentCon.prepareStatement(query);
pst.setString(1, username);
ResultSet rs = pst.executeQuery();
while (rs.next())
{
//Your logic for display
out.println(<html>Whole html logic can be written here</html>);
}
だから今、サーブレットを実行し、その結果をブラウザ上に表示されます。
Googleを一度だけ使用すれば、それに応じて数多くの例を使用して修正することができます。 –