Code example for PrintWriter

Methods: close, println

0
 
    @Override 
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();
        out.println("<HTML>");
        out.println("<HEAD><TITLE>Bootstrap CDI in Jetty</TITLE></HEAD>");
        out.println("<BODY>");
        out.println(saySomething());
        out.println("</BODY>");
        out.println("</HTML>");
        out.close();
    } 
 
    public String saySomething() {
        return hello.sayHelloWorld();
    } 
}