Sunday, March 4, 2018

Advance Java Programming : A Servlet program

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

//extend HttpServlet class
public class Servlet_1 extends HttpServlet
{
    private String message;
   
    public  void init() throws ServletException
    {
        // do initialization
        message="Ashutosh Singh";
    }
   
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
    {
        //set  response content type
        response.setContentType("text/html");
        // actual logic goes here
        PrintWriter out =response.getWriter();
        out.print("<html><body>");
        out.print("<h1>"+message+"</h1>");
        out.print("</body></html>");
    }
   
    public void destroy()
    {
        //do nothing
    }
}

Thanks
Happy programming !

No comments:

Post a Comment

Sacred Thought

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...