I am new to JSP.
I am devoloping an employee maintenance system. I have a MS-Access database in which emmployee number is stored in a table. How can I retrieve the column values and display them in a combo box in the JSP page ?
Since you are using JSP you can write in both HTML and Java, this approach is similar to what you would do in PHP as well.
Please forgive any syntax mistakes, I'm just portraying a general concept.
<!-- HTML: open the form and combo box tags -->
//JSP: Set up your DB call and SQL stmt
String sqlStmt = "SELECT VALUE, TEXT FROM DBTABLE";
PreparedStatement = new PreparedStatement(dbconnection, sqlStmt);
ResultSet rslt = preparedString.execute();
String comboValue = rslt.getString(1);
String comboText = rslt.getString(2);
<!-- HTML: use the DB rslt values to build your HTML combo box -->
//JSP: Close the loop
<!-- HTML: close the combo box and form tags -->
You can also just use print statements throughout one JSP section to avoid switching back and forth between Java and HTML.
Hope this helps.