i have read many posts that scriptlets is a bad practice so finally i decided to avoid this too. I have developed a project using struts framework in which mostly jsp pages have java code. And now i wanted to remove that code from my all the pages.
<%@page import="java.sql.ResultSet"%>
<%@page import="com.pra.sql.SQLC"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<table align="left" width="346" border="0">
<tr><td align="center" colspan="3" style="font-size:20px;">Tests We Provide</td></tr>
<tr>
<th width="80" height="38" nowrap>Test ID</th>
<th width="200" nowrap>Test Name</th>
<th width="144" nowrap>Test Fee</th>
</tr>
<%
String sql = "Select TestID,tname,tfee from addtest order by tname";
ResultSet rs = SQLC.getData(sql, null);
while (rs.next()) {
String testid = rs.getString("TestID");
String testname = rs.getString("tname");
String testfee = rs.getString("tfee");
%>
<tr>
<td width="80" height="34" nowrap><%=testid%></td>
<td width="200" nowrap><%=testname%></td>
<td width="144" nowrap><%=testfee%></td>
</tr>
<%
}
%>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With