ConnectionPool cpool=(ConnectionPool)application.getAttribute("ConnectionPool");
while(cpool==null)
{
%>
cpool=(ConnectionPool)application.getAttribute("ConnectionPool");
}
Connection con=cpool.getConnection();
Statement stm=con.createStatement();
String sQuery="SELECT NEWS_ID,NEWS_DATE,NEWS_TITLE FROM NEWS ORDER BY NEWS_DATE DESC LIMIT 0,15";
ResultSet rlt=stm.executeQuery(sQuery);
sQuery="select ID from pics_image order by ID asc LIMIT 1, 1";
ResultSet rpt=stm.executeQuery(sQuery);
while(rpt.next())
{
//String Pic_Count=rpt.getString("ID");
pp=rpt.getString("ID");
out.print(pp);
}
out.print(pp);
rpt.close();
cpool.returnConnection(con);
cpool=null;
con=null;
%>
代码是这样的 如果把out.print放在while里面网页可以显示 但是如果放到外面就会报错。。如果其他地方调用PP这个变量一样会报错。。我主要是想调用这个变量。。请问有什么方法可以不出错?
错误代码是
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented
it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 29 in the jsp file: /MYSQLTEST.jsp
The local variable pp may not have been initialized
26: pp=rpt.getString("ID");
27:
28: }
29: out.print(pp);
30: rpt.close();
31: cpool.returnConnection(con);
32: cpool=null;
展开