JSP partially renders sometimes

--------------------------------------------------------------------------------

Most of the time, the JSP renders correctly. But every now and then, it doesn't render completely. It always cuts off the html code at the same point...a very random point in the code may I add. It cuts off before I call the getFaculty() method.

I thought it may have been a problem with not closing the connection and/or statement. But, in that case, the page probably wouldn't render at all (blank page). This never happens, though.

This is running on a Tomcat server. When the page doesn't render completely, I just reload the app, and it works again (for about a week until it happens again). Is there something that is reset by Tomcat when it is reloaded? Can I code this in the JSP?

I have other pages that are EXACTLY the same, but they always render completely. However, this is the first page that comes up, so it is viewed the most.

Another thing is that the jspInit() method isn't always called. That is why I check to make sure there is a connection in the getFaculty() method. If not, it will connect. Just thought I'd clarify that in case some of you were wondering.

Any help would be greatly appreciated! Thanks!


[CODE]
<%
letter = request.getParameter("letter");
research = request.getParameter("research");
status = request.getParameter("status");
faan = request.getParameter("faan");

String jspPath = getServletContext().getRealPath(request.getServlet Path());
File jspFile = new File(jspPath);
Long lastModified = jspFile.lastModified();
java.util.Date date = new java.util.Date(lastModified);
%>
<%!
public void jspInit() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
conn = DriverManager.getConnection(REMOVED FOR PRIVACY);
stmt = conn.createStatement();
} catch (Exception ex) { }
}
public void jspDestroy() {
try {
stmt.clearBatch();
stmt.close();
conn.close();
} catch (Exception ex) { }
}

ArrayList facs = new ArrayList();
Faculty fac = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String letter = null;
String research = null;
String status = null;
String faan = null;

void getFaculty() throws ServletException {
try {
try {
rs = stmt.executeQuery("select * from faculty where primkey='_'");
rs.close();
} catch (SQLException ex) {
conn = DriverManager.getConnection(REMOVED FOR PRIVACY);
stmt = conn.createStatement();
}

facs = new ArrayList();
if (letter!=null) {
rs = stmt.executeQuery("select * from FACULTY where lname like '"+letter+"%' order by lname");
} else if (research!=null) {
rs = stmt.executeQuery("select * from FACULTY where research is not null and datalength(research)>0 order by lname");
} else if (status!=null) {
rs = stmt.executeQuery("select * from FACULTY where status='"+status+"' order by lname");
} else if (faan!=null) {
rs = stmt.executeQuery("select * from FACULTY where credentials like '%FAAN%' order by lname");
} else {
rs = stmt.executeQuery("select * from FACULTY order by lname");
}
while (rs.next()) {
fac = new Faculty();
fac.setFname(rs.getString("fname"));
fac.setMi(rs.getString("mi"));
fac.setLname(rs.getString("lname"));
fac.setPhone(rs.getString("phone"));
fac.setPrimkey(rs.getString("primkey"));
fac.setStatus(rs.getString("status"));
fac.setImage(rs.getString("image"));
facs.add(fac);
}
rs.close();

try {
stmt.clearBatch();
stmt.close();
conn.close();
} catch (Exception ex) { }

} catch (SQLException ex) { throw new ServletException(ex); }
}
%>
[CODE]