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 8935067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:54:49+00:00 2026-06-15T09:54:49+00:00

I have a database flights_DB containing a table called Passengers . Each passenger is

  • 0

I have a database flights_DB containing a table called Passengers. Each passenger is uniquely identified by his passport number.

I would like to create a drop-down list containing all the passport numbers in the table Passengers. How can I achieve this using JSP and Servlets?

  • 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-06-15T09:54:50+00:00Added an answer on June 15, 2026 at 9:54 am

    Assuming that you’ve the model and DB part already finished (as per the comments on the question), just create a servlet class and implement the doGet() method accordingly. It’s relatively simple, just retrieve the list of passengers from the DB, store it in request scope and forward to the JSP which should present it. The below example assumes that you’re using EJB/JPA as service/DB layer, but whatever service/DB layer you use, you should ultimately end up getting a List<Passenger> from it anyway.

    @WebServlet("/passengers")
    public class Passengers extends HttpServlet {
    
        @EJB
        private PassengerService service;
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            List<Passenger> passengers = service.list();
            request.setAttribute("passengers", passengers);
            request.getRequestDispatcher("/WEB-INF/passengers.jsp").forward(request, response);
        }
    
    }
    

    Create a JSP file /WEB-INF/passengers.jsp which uses JSTL <c:forEach> to iterate over it, printing a new HTML <option> everytime:

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    ...
    <select name="passenger">
        <c:forEach items="${passengers}" var="passenger">
            <option value="${passenger.id}"><c:out value="${passenger.name}" /></option>
        </c:forEach>
    </select>
    

    (this example assumes the Passenger entity to have id and name properties)

    That should basically be it. Just open the page by invoking the servlet’s URL like so http://example.com/contextpath/passengers.

    See also:

    • doGet and doPost in Servlets
    • Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
    • Populating cascading dropdown lists in JSP/Servlet
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a local sqlite server. The SQL database only contains a table called
i have database table like this +-------+--------------+----------+ | id | ip | date |
that my problem: I have database table like that: id (AI) market_id 1 6
I have quite a few situations where I have database structures similar to: TABLE
I have database with users table where i have many columns include passwords and
I have database A and database B. I would like to do one way
I have database with many tables. In the first table, I have a field
I have database in which data is imported from the other table. if data
I Have Database that contains 4 tables TABLE TBLCARTITEM (CART_ID, ITEM_ID, PROMOTION_ID, many more
I have database table Inbox(id,accountid,emailfrom,emailsubject,emailbody, recieveddate,attachment, read(bool) i have added it to the form

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.