Rahul Verma

Rahul Verma

  • NA
  • 23
  • 4.4k

JSTL(java) or java

Jun 28 2016 7:22 AM

How to Fetch Records From Database Using JSTL in JSP page of Java

<%
try{
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/atten?" + "user=root&password=xxxx");
Statement statement = connection.createStatement() ;
resultset =statement.executeQuery("select distinct time_table_class_id from time_table_details" ) ;
%>
<center>
<h1> Drop down box or select element</h1>
<select id="semester" onchange="loadSemester();">
<% while(resultset.next()){ %>
<option value="<%= resultset.getString(1)%>"><%= resultset.getString(1)%></option><br>
<% } %>
</select>
<input type="submit" name="Submit" value="click">
</center>
<%
}
catch(Exception e)
{
out.println("wrong entry"+e);
}
%>
In this code drop down created but I want to when select a list from drop down, and clicking on click button all the data regarding fetch from database? Everything happen on same page.