import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class hello extends HttpServlet { /** * Handle the HTTP GET method by building a simple web page. */ public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { PrintWriter out; String title = "Hello Servlet"; // set content type and other response header fields first response.setContentType( "text/html" ); // then write the data of the response out = response.getWriter(); out.println( "<html><head><title>" ); out.println( title ); out.println( "</title></head><body>" ); out.println( "<h1>" + title + "</h1>" ); out.println( "<p>This is output from " + title + ".</p>" ); out.println( "</body></html>" ); out.close(); } }