Java examples for Servlet JSP:Servlet
The Servlet Template
package com.mycompany; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; class MyServlet extends HttpServlet { public void init() throws ServletException { // Initialization code... // See Getting and Setting Initialization Parameters for a Servlet } public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter out = resp.getWriter(); out.println("<html><head><title>A Simple Servlet</title></head><body>"); out.println("Today is "+(new java.util.Date())); out.println("</body></html>"); out.close(); } public void destroy() { // Shutdown code... } }