Rahul Verma

Rahul Verma

  • NA
  • 23
  • 4.4k

fetching data from database using jstl and html

Jun 29 2016 4:28 AM
I'm using jstl with html in this code if hard-coded in input field, when click on submit button not display the data from database in my project. But while creating one more jsp page and paste these code into jsp and when run jsp page it shows the data regarding hard coded. But it not working in my project when combining.
 
 
<FORM ACTION="viewTimeTable.jsp" METHOD="POST">
<BR>
<INPUT TYPE="TEXT" NAME="id">
<BR>
<INPUT TYPE="SUBMIT" value="Submit">
</FORM>

<%
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/attendance?" + "user=root&password=abhi");
Statement statement = connection.createStatement();
String id = request.getParameter("id");
ResultSet resultset = statement.executeQuery("select * from time_table_details where time_table_class_id = '" + id + "'") ;
if(!resultset.next()) {
} else {
%>

<TABLE BORDER="1">
<TR>
<th>Time_table_id</th>
<th>Time_table_class_id</th>
<th>day</th>
<th>lecture</th>
<th>time_table_subject_id </th>
<th>Time_table_teacher_id</th>
<th>class_councillor1 </th>
<th>class_councillor2 </th>
<th>status </th>
</TR>
<TR>
<TD> <%= resultset.getInt(1) %> </TD>
<TD> <%= resultset.getString(2) %> </TD>
<TD> <%= resultset.getString(3) %> </TD>
<TD> <%= resultset.getString(4) %> </TD>
<TD> <%= resultset.getString(5) %> </TD>
<TD> <%= resultset.getString(6) %> </TD>
<TD> <%= resultset.getString(7) %> </TD>
<TD> <%= resultset.getString(8) %> </TD>
<TD> <%= resultset.getString(9) %> </TD>

</TR>
</TABLE>
<BR>
<%
}
%>

Answers (1)