#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Australia
    Posts
    0
    Rep Power
    0

    displaying data in a select box using JSP


    I'm hoping someone can help with displaying data from a db into a select box using JSP. Can work out the SQL, just not how to actually display the data.

    have been unable to find any examples/info on select boxes so far, any suggestions would be much appreciated!
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    India
    Posts
    7
    Rep Power
    0
    <%@ page import = “java.sql.*” %>
    <HTML>
    <BODY>
    <%
    Connection con = DriverManager.getConnection("url",uid","pwd");
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("Select colname from ur table");
    out.println("<SELECT>");
    while (rs.next()){
    out.println("<OPTION>" + rs.getString(colname) + "</OPTION>");
    }
    out.pritln("</SELECT>);

    %>
    </BODY>
    </HTML>

IMN logo majestic logo threadwatch logo seochat tools logo