Java HttpServlet extend
import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); /* Display some response to the user */ out.println("<html><head>"); out.println("<title>First Servlet</title>"); out.println(// w ww. j a va 2s .c o m "\t<style>body { font-family: 'Lucida Grande', " + "'Lucida Sans Unicode';font-size: 13px; }</style>"); out.println("</head>"); out.println("<body>"); out.println("<p>This is a simple servlet!</p>"); out.println("</body></html>"); out.close(); } }