Design Your Own Page (Java Servlet)

Background color:
Title:
Your Message:

 


Servlet Source Code


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

public class DesignPageServlet extends HttpServlet
{

  //Initialize global variables
  public void init(ServletConfig config) throws ServletException
  {
    super.init(config);
  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
    String sBKCOLOR = request.getParameter("BKCOLOR");
    String sTITLE = request.getParameter("TITLE");
    String sMESSAGE = request.getParameter("MESSAGE");

    response.setContentType("text/html");
    PrintWriter out = new PrintWriter (response.getOutputStream());
    out.println("<html>");
    out.println("<head><title>" + sTITLE + "</title></head>");
    out.println("<body bgColor=" + sBKCOLOR + ">");
    out.println("<h1>" + sTITLE + "</h1>");
    out.println("<br><br>" + sMESSAGE);
    out.println("</body></html>");
    out.close();
  }
}