Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 934725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:02:48+00:00 2026-05-15T21:02:48+00:00

I know this has been asked before, but it just doesn’t work for me.

  • 0

I know this has been asked before, but it just doesn’t work for me.

I’m trying to populate a drop down list from a database using jstl, here’s the class i use as a usebean:

public class feedData {

    Connection con;

    public feedData() throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {

        Class.forName("com.mysql.jdbc.Driver").newInstance();
        String url = "******";

        con = DriverManager.getConnection(url, "**", "**");

    }

    public ArrayList<String> getUnis() throws SQLException {
        ArrayList<String> uniList = new ArrayList<String>();
        String tryquery = "select aff from libra.smalluniqdbtmp";
        Statement stmt2 = con.createStatement();
        ResultSet rs1 = stmt2.executeQuery(tryquery);

        while (rs1.next()) {

            uniList.add(rs1.getString("aff"));

        }

        return uniList;
    }

    public ArrayList<String> getRI() throws SQLException {
        ArrayList<String> RIList = new ArrayList<String>();
        String tryquery = "select interest from libra.riuniqdb";
        Statement stmt2 = con.createStatement();
        ResultSet rs1 = stmt2.executeQuery(tryquery);

        while (rs1.next()) {

            RIList.add(rs1.getString("aff"));

        }

        return RIList;
    }
}

Here’s my jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

        <jsp:useBean id="obj" scope="page" class="uiLibraWeb2Pkg.feedData" />
        <h1>Hello World!</h1>
        <table border="1">
            <thead>
                <tr>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> <form action="response.jsp">
                            <strong>Select a university:</strong>

                            <select name="affiliation">
                                <c:forEach var="aff" items="${obj.unis}">
                                    <option value="${aff}"></option>
                                </c:forEach>

                            </select>

                        </form>

                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </tbody>
        </table>

    </body>
</html>

There are no error messages in the server log and in the build output of the project, but the drop down list is empty. Been struggling with this, and I have no clue as to what’s wrong. I also tried to set a data source and do it using jstl iterating through the resultset of the query, but that acted the same way.

Now i’m not relying on any data source, but still the same results.

Help appreciated,
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:02:48+00:00Added an answer on May 15, 2026 at 9:02 pm

    I have not tested your code, but please add a breakpoint in the server side to check how many elements you have in the list. Maybe it is also empty in the server side.

    The second point is that this code

    <option value="${aff}"></option>
    

    doesn’t show anything to the user, because it is rendered in HTML as an option with no text. Maybe it should be

    <option value="${aff}">${aff}</option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.