Adv Java - [Servlet: Basic Example]

♠ Posted by Unknown in at 08:28

Basic Servlet Example


Write a Servlet program that display “Welcome to the world of Servlet” using a single link.


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

public class ServletMCA01 extends HttpServlet
{
            public void service(HttpServletRequest req, HttpServletResponse res) throws IOException
            {
                        res.setContentType("text/html");
                        PrintWriter out = res.getWriter();
                        out.print("<HEAD><TITLE>");
                        out.print("MCA01 Servlet Program");
                        out.print("</TITLE></HEAD><BODY>");
                        out.print("<H1>Wel-come to the world of Servlet</H1></BODY>");
                        out.close();
            }

}
Image: Servlet Example

0 comments:

Post a Comment