
In one of my jsp i have used for loop. in every iteration it will fetch value from db and print it on heading section, it prints vertically but my requirement is to print it horizontally, can anyone suggest any idea. please see the code which i have used below :
<% for(int Count = 0; Count < numberOfcase; Count++){
String Name = (String)List.get(Count);%>
<dd/>
<table border = "1">
<tr style = "background-color:Navy;color:White;">
<th></th>
<th><%= Name %></th>
<th></th>
</tr>
<tr>
<th>Time</th>
<th>Successful</th>
<th>Unsuccessful</th>
</tr>
<%
try{
rs = stmt.executeQuery(queries[Count]);
while (rs.next()) {
startDate = rs.getString(1);
endDate = rs.getString(2);
ID = rs.getString(3);
successCount = rs.getString(4);
failureCount = rs.getString(5);
//out.println(startDate+" "+endDate+" "+ID+" "+successCount+" "+failureCount); %><br/>
<tr>
<th><%= endDate %></th>
<th><%= successCount %></th>
<th><%= failureCount %></th>
</tr>
<% }
}catch(Exception e){
Thanks in advance

<%@ page import="java.sql.*"%>
<html>
<body>
<form method="POST">
<%
int l=0;
int rowcu=0;
int totalRecords=0;
ResultSetMetaData rsmt=null;
ResultSet rs=null;
String query="select * from person";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st1=conn.createStatement();
Statement st2=conn.createStatement();
Statement st3=conn.createStatement();
ResultSet rs1=st1.executeQuery(query);
ResultSet rs2=st3.executeQuery(query);
int x=0;
while(rs2.next()){
x++;
}
rs1.next();
rsmt=rs1.getMetaData();
l=rsmt.getColumnCount();
rs=st2.executeQuery(query);
%>
<table border="1" >
<tr>
<%for(int v=1;v<=l;v++){
String cnames=rsmt.getColumnName(v);
%>
<td ><%=cnames.toUpperCase()%></td>
<%
}
%>
</tr>
<%
while(rs.next()){
%>
<tr>
<%
for(int vc=1;vc<=l;vc++){
%>
<td><%=rs.getString(vc)%></td><%
}
}%>
</tr>
</table>
<%
}
catch(Exception e1){
}
%>
</body>
</html>
For more information, visit the following link:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.