GRAPHIC JAVAThe evolution of Java Server Pages

GRAPHIC JAVA
The evolution of Java Server Pages

David Geary

Listing 1. A simple servlet.


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

public class DateServlet extends HttpServlet {
	public void service(HttpServletRequest req,
                             HttpServletResponse res)
                             throws IOException, ServletException {
		PrintWriter out = res.getWriter();
		
		out.println("<html>");
		out.println("<head><title>Date Servlet</title></head>");
		out.println("<body><h2>Today's Date:</h2>");
		out.println(new java.util.Date());
		out.println("<body></html>");
	}
}

About the Author

David Geary was the lead engineer for the Java Management API GUI toolkit, and is now an independent Java consultant. David is the author of Graphic Java—Mastering the JFC. He can be contacted at [email protected].