|
NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
|
| INTERACTIVE WEB SERVICES WITH JAVA |
|
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>Servlet</title></head>");
out.println("<body><h1>Hello World!</h1>");
out.println("This page was last updated: " + new java.util.Date());
out.println("</body></html>");
}
}
|
Useful methods in HttpServlet to be implemented in sub-classes:
Useful predefined methods:
Exceptions: ServletException
|
| COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |
|