Com Mycompany MyServlet

package com.mycompany;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {
    // This method is called by the servlet container just before this servlet
    // is put into service. Note that it is possible that more than one
    // instance of this servlet can be created in the same VM.
    public void init() throws ServletException {
        // Initialization code...
        // See Getting and Setting Initialization Parameters for a Servlet
    }

    // This method is called by the servlet container to process a GET request.
    // There may be many threads calling this method simultaneously.
    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();
    }

    // This method is called by the servlet container just after this servlet
    // is removed from service.
    public void destroy() {
        // Shutdown code...
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.