//显示最后一条信息
public ArrayList selectlastone(){
ArrayList list=new ArrayList();
String sql="select top 1 * from log order by time desc";
PreparedStatement ps=null;
ResultSet rs=null;
Connection con=DBUtil.getConnection();
try {
ps=con.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next()){
log log=new log();
log.setId(rs.getString("id"));
log.setContext(rs.getString("context"));
log.setText(rs.getString("text"));
log.setTime(rs.getString("time"));
list.add(log);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
在jsp中显示信息(此jsp需要在另外一个jsp中引用 但是报错为 Unable to compile class for JSP: )
<%@ page language="java" import="java.util.*,UI.*,Dao.*" pageEncoding="utf-8"%>
<html>
<head>
<style type="text/css">
.td {
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: none;
border-right-style: none;
border-bottom-style: dashed;
border-left-style: none;
border-top-color: #ffffff;
border-right-color: #ffffff;
border-bottom-color: #ffffff;
border-left-color: #ffffff;
}
</style>
</head>
<body>
<%
LogDao dao=new LogDao();
ArrayList list=dao.selectlastone();
for(int i=0;i<list.size();i++)
{
log log=(log)list.get(i);
%>
<table width="100%" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td height="80" align="left" valign="middle" class="td"><a href="see_log.jsp">
<font color="#FFFFFF" size="-1">内容:<%=log.getContext() %></font></a></td></tr>
<tr><td height="30" align="right" valign="bottom"><font color="#FFFFFF" size="-1">时间:<%=log.getTime() %></font></td></tr>
</table>
<%}%>
</body>
</html>
求助 :初学者..帮帮忙!!谢谢!!!