package MyPkg

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

public class HelloServlet extends HttpServlet

{

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException

{

res.setContentType(“text/html”);

PrintWriter out = res.getWriter();

out.println(“<html><head><title>Hello Servlet</title></head>”);

out.println(“<body>”);

out.println(“<h1>Hello World!!!</h1>”);

out.println(“</body></html>”);

}

}

 

o/p

Hello World

Advertisements