display data from servlet to drop down menu jsp
<p>I am trying to avoid java codes in jsp for drop down menu. i dont know if my codes are correct in the first place (i bet there are other errors) BUT my real problem is, i dont know how to allow drop down menu in JSP to receive data from servlet. Basically I want the user to select any lecturer name from drop down menu, then it will display the chosen lecturer's information to update (well, thats another story). I hope someone can help. Thank you in advance!</p>

<p>this is my jsp code:</p>

<pre><code>&lt;form action="updateLecturer" class="sky-form"&gt;
&lt;header&gt;Update Lecturer Information&lt;/header&gt;
&lt;center&gt;
&lt;fieldset&gt;

&lt;section&gt;
&lt;label class="select"&gt;
&lt;select name="selectLecturer" id="lecturerFullname"&gt;
&lt;option value="0" selected disabled&gt;Lecturers Name&lt;/option&gt;        
**&lt;option name="lecturerFullname"&gt;I HAVE PROBLEM IN HERE!!!&lt;/option&gt;** 
&lt;/select&gt;

&lt;/label&gt;
&lt;/section&gt;

&lt;/center&gt;
&lt;footer&gt;
&lt;center&gt;&lt;button type="submit" class="button"&gt;Update&lt;/button&gt;&lt;/center&gt;
&lt;/footer&gt;
&lt;/form&gt;
</code></pre>

<p>This is my servlet (not sure if its right anyway):</p>

<pre><code>public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, java.io.IOException {


        try {

            LecturerBean lecturer = new LecturerBean();
   lecturer.setLecturerFullname(request.getParameter("lecturerFullname"));

                        response.sendRedirect("updateLecturer.jsp");


        }

        catch (Throwable theException) {
            System.out.println(theException);
        }
    }
</code></pre>

<p>This is my web.xml file :</p>

<pre><code>&lt;servlet&gt;
        &lt;servlet-name&gt;UpdateLecturerServlet&lt;/servlet-name&gt;
        &lt;servlet-class&gt;CSP600.UpdateLecturerServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;UpdateLecturerServlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/updateLecturer&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
</code></pre>

<p>This is my DAO:</p>

<pre><code> static Connection currentCon = null;
    static ResultSet rs = null;

    public static LecturerBean lecturerlogin(LecturerBean Lbean) {

        // preparing some objects for connection
        System.out.println("JIJIJI");
        Statement stmt = null;

        String lecturerID = Lbean.getLecturerID();
        String lecturerFullname = Lbean.getLecturerFullname();
        String lecturerPassword = Lbean.getLecturerPassword();

        System.out.println("j444444");


        String searchQuery = "select lecturerfullname from lecturer";

        System.out.println("Your lecturer is " + lecturerFullname);

        System.out.println("Query: " + searchQuery);

        try {
            // connect to DB
            currentCon = JavaConnectionDB.getConnection();
            stmt = currentCon.createStatement();
            rs = stmt.executeQuery(searchQuery);
           // boolean more = rs.next();

            while(rs.next())
            {
            rs.getString(lecturerFullname);
            }
        }

        catch (Exception ex) {
            System.out.println("Log In failed: An Exception has occurred! " + ex);
        }

        // some exception handling
        finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (Exception e) {
                }
                rs = null;
            }

            if (stmt != null) {
                try {
                    stmt.close();
                } catch (Exception e) {
                }
                stmt = null;
            }

            if (currentCon != null) {
                try {
                    currentCon.close();
                } catch (Exception e) {
                }

                currentCon = null;
            }
        }

        return Lbean;

    }
</code></pre>