FileDocCategorySizeDatePackage
TestLongServlet.javaAPI DocExample1408Mon Dec 18 20:25:54 GMT 2000None

TestLongServlet

public class TestLongServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

  Connection conn = CacheConnection.checkOut();
  Statement  stmt = null;
  ResultSet  rslt = null;

  res.setContentType("text/plain");
  PrintWriter out = res.getWriter();

  try {
   stmt = conn.createStatement();
   rslt = stmt.executeQuery(
    "select biography from person_biography");
   if (rslt.next()) {
    char[] buffer = new char[32];
    int    length = 0;
    Reader in = rslt.getCharacterStream(1);
    while ((length = in.read(buffer)) != -1) {
     out.write(buffer, 0, length);
    }
    rslt.close();
    rslt = null;
   }
   else {
    res.setContentType("text/html");
    out.println("<html><head><title>Person Biography</title></head>");
    out.println("<body><h1>No data found</h1></body></html>");
    return;
   }
   stmt.close();
   stmt = null;
  }
  catch(SQLException e) {
   System.out.println("SQLException cause: " + e.getMessage());
  }
  finally {
   if (rslt != null) 
    try { rslt.close(); } catch (SQLException ignored) {}
   if (stmt != null) 
    try { stmt.close(); } catch (SQLException ignored) {}
  }
  CacheConnection.checkIn(conn);