O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating JSP Pages

When Java first came to the Web, you used Java servlets to create interactive web pages. Servlets are compiled Java code, and they take a little bit of practice to write. For example, here's a servlet that displays the text “Hello there!” in an HTML page:

 import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Sample extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<HTML>"); out.println("<HEAD>"); out.println("<TITLE>"); out.println("A Web Page"); out.println("</TITLE>"); out.println("</HEAD>"); out.println("Hello there!"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required