// get session HttpSession session = request.getSession(); // get session attribute for authentication Boolean authenticated = (Boolean) session.getAttribute("authenticated"); response.setContentType("text/html"); String docType = ""; String html = ""; PrintWriter clientOutput = response.getWriter(); // generate the response document clientOutput.println(docType); clientOutput.println(html); if (authenticated == null ) { clientOutput.println("Not Authenticated"); clientOutput.println(""); clientOutput.println("

Not Authenticated

"); clientOutput.println("

You are not supposed to be here. You must login first.

"); } else { clientOutput.println("Authenticated!"); clientOutput.println(""); clientOutput.println("

Authenticated!

"); clientOutput.println("

Welcome to the promised land!:

"); } clientOutput.println(""); clientOutput.println(""); clientOutput.close();