0 Replies - 681 Views - Last Post: 07 September 2015 - 07:53 PM

#1 SREEMANTH   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-September 15

Problem with populating DropDownList with data from DataBase

Posted 07 September 2015 - 07:53 PM

Hi Guys,
I am new to JAVA.I am trying to populate my DropDownList with column data from table in Oracle database I have created.But the data is not appearing in the DropDown list of JSP.I am posting the code snippets and screen shots of my project.Please help me so that I can move forward.

My File structure
Posted Image

<%@ page language="java" contentType="text/html; charset=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">

<%@ page import="java.sql.*" %>
<%ResultSet resultset =null;%>
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$( "#date" ).datepicker();
<form name="carselect">
<select name="CAR">
<c:forEach items="${Data}" var="d">
<option value="${d.id}">${d.name}</option>
<h4><a href="HOME.jsp">HOME</a></h4>

My Servlet(Testdb.java)
package com.sigma.carrental.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

public Testdb() {


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


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

Connection con=null;
ResultSet rs=null;

try {
} catch (ClassNotFoundException e) {

System.out.println("NO DRIVER");

try {
con=DriverManager.getConnection("jdbc:oracle:thin: @localhost:1521:XE","SYSTEM","ORACLE");
} catch (SQLException e) {
System.out.println("conncetion failed");;

Statement st=con.createStatement();
rs=st.executeQuery("select * from RENTACAR.CARLIST");
catch(SQLException e)
System.out.println("statement cretion failed");

List a1=new ArrayList();

try {
try {
} catch (SQLException e) {
// TODO Auto-generated catch block
} catch (SQLException e) {
// TODO Auto-generated catch block

request.setAttribute("Data", a1);	
request.getRequestDispatcher("/WEB-INF/RENT.jsp").forward(request, response);

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



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">



Is This A Good Question/Topic? 0
  • +

Page 1 of 1