Basic Servlet Program

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class HtmlSrv extends HttpServlet {

  
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet HtmlSrv</title>");           
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet HtmlSrv at " + request.getContextPath() + "</h1>");
            out.println("<body>");
            out.println("<table border='1'><tr>");
            out.println("<th>celebrity</th>");
            out.println("<th>profession</th>");
            out.println("<tr><td>sachin</td></tr>");
            out.println("<td>ccricketer</td>");
            out.println("<tr><td>dulquer salman</td></tr>");
            out.println("<td>hero</td>");
            out.println("<tr><td>federer</td></tr>");
            out.println("<td>tennis star</td>");
           
           
            out.println("</body>");
            out.println("</html>");
            out.close();
        }
    }
}

Comments

Popular posts from this blog

Java Beans Program

MACHINE LEARNING IN REAL WORLD

MACHINE LEARNING INTRODUCTION