Monday, March 10, 2008

Print ResultSet in HTML

View JSP code

<>

< id="viewbean" scope="page" class="imsi.ViewBean">

< name="viewbean" property="data" value="">
<>here we have results< /h3>
<><>
< name="viewbean" property="data">
<><>
<>it worked..!< /h3>




related JAVA class code(imsi.ViewBean.java)



private String data;



public String getData() {
return this.data;
}

public void setData(String data) {


DBConnection db = new DBConnection();
db.dbConnect();

ResultSet result = null;

result = db.execute("select * from `mod_im` where mobile_no='0714280979'");
try {

// for (int i = 1; result.getRow() < data="" border="'1'">";
this.data=this.data+"< bgcolor="'#8dc4fc'"><><> Mobile Number < /b>< /td>";
this.data=this.data+"<><> Old IMSI number < /b>< /td>";
this.data=this.data+"<><> New IMSI number < /b>< /td>";
this.data=this.data+"<><> IMSI changed by < /b>< /td>";
this.data=this.data+"<><> IMSI changed on < /b>< /td>";
this.data=this.data+"<><> Time changed < /b>< /td>< /tr>";

while (result.next()) {


this.data=this.data+"<><>";
for (int i = 1; i<7; data="this.data+result.getString(i)+"><>";

}
this.data=this.data+"< /tr>";

}
this.data=this.data+"< /table>";

} catch (SQLException ex) {
ex.printStackTrace();
}

System.out.print(this.data);


}

No comments: