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

  • SEARCH
  • Home
  • 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 8213841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:15:24+00:00 2026-06-07T11:15:24+00:00

I’m trying to learn Servlets/JSP. When I tried the following code I dont get

  • 0

I’m trying to learn Servlets/JSP. When I tried the following code I dont get any output. Can someone please help me? When I run the code I get only the header and I dont see the values showing up in the dropdown.

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class VacationTrackerDAO {

public static List<VactionTrackerBean> list() throws SQLException{
    List<VactionTrackerBean> appr= new ArrayList<VactionTrackerBean>();

    try{

        DBConnection conObj=new DBConnection(); 
        Connection dbCon= conObj.getCon();
        Statement stmt=conObj.getStmt();
        String queryCPList="select * from Capacity_Plan";
        String queryApprList="Select First_Last_Name from Vacation_Approvers";
        PreparedStatement preStmtCPList=dbCon.prepareStatement(queryCPList);//get metadat
        PreparedStatement preStmtApprList=dbCon.prepareStatement(queryApprList);//get names
        //ResultSet rsCPList=preStmtCPList.executeQuery();
        ResultSet rsApprList=preStmtCPList.executeQuery();

        //ResultSetMetaData metaCPList=rsCPList.getMetaData();

        VactionTrackerBean vtBean=new VactionTrackerBean();
        while(rsApprList.next()){
            vtBean.setApprover((rsApprList.getString("First_Last_Name")));
            appr.add(vtBean);
        }


}catch(Exception e){
    System.out.println("In the Vacation TrackerDAO.java class:"+e);
}
return appr;

}
}

Bean:

 public class VactionTrackerBean {

private String dates;
private String approver;
public String getDate() {
    return dates;
}
public void setDate(String dates) {
    this.dates = dates;
}
public String getApprover() {
    return approver;
}
public void setApprover(String approver) {
    this.approver = approver;
}



}

Servlet:

public class VacationTracker extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException {

    doPost(request, response);

}


protected void doPost(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException {

    try{


    List<VactionTrackerBean> vacTracker=VacationTrackerDAO.list();
    request.setAttribute("vacTracker", vacTracker);
    request.getRequestDispatcher("WEB-INF/VacationTracker.jsp").forward(request,response);

    }catch (SQLException e){
        System.out.println("Error in VacationTracker.java due to VactionTrackerDA.java:"+e);
        request.getRequestDispatcher("WEB-INF/Error.jsp").forward(request,response);
    }

}
}

JSP Page:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!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=ISO-8859-1">
<title>Vacation Tracker</title>  
</head>
<body>

<h1> Vacation Tracker </h1>

 <div id="main">

<c:forEach items="${vacTracker}" var="vacTracker"> 
<select id="myselect" name="mydata" size="10"> 
<option value="${vacTracker.approver}">${vacTracker.approver}</option>
</select>   
</c:forEach>

</div>


</body>
</html>
  • 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-07T11:15:26+00:00Added an answer on June 7, 2026 at 11:15 am

    Check you are getting values in list.Put some S.O.P after while loop in DAO class.

    Also,There is a mistake in code. It should be

    <select id="myselect" name="mydata" size="10"> 
    <c:forEach items="${vacTracker}" var="vacTracker"> 
      <option value="${vacTracker.approver}">${vacTracker.approver}</option>
    </c:forEach>
    </select>   
    

    Otherwise, It will create new select for each item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.