is it possible to display html in the init method like you can do

Java Code:
res.setContentType ("text/html");
PrintWriter out = res.getWriter();
out.println("html");
in a doGet or doPost.
i set my database connection in the init() method and watch to display error on page if any error occur connecting