J. Blustein

Web-centric Computing

Some Example Code

Servlet Examples: HelloClientServlet

Source Code

//
// HelloClientServlet 1.0 by Stefan Zeiger
// From <URL:http://novocode.de/doc/servlet-essentials/chapter2a.html#2_1>
//

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

public class HelloClientServlet extends HttpServlet
{
  protected void doGet(HttpServletRequest req,
                       HttpServletResponse res)
            throws ServletException, IOException
  {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>"+
                "</HEAD><BODY>Hello Client!</BODY></HTML>");
    out.close();
  }

  public String getServletInfo()
  {
    return "HelloClientServlet 1.0 by Stefan Zeiger";
  }
}
  

[see how it is compiled]


http://www.cs.dal.ca/~jamie/course/CS/4173/examples/servlets/Hello/source.html
Version:
29 Oct 2001
CS 4173 Prof:
J. Blustein <jamie@cs.dal.ca>

Valid XHTML 1.0!