Java .

Java Servlets

A Hello World Servlet - HelloWorldServlet.java

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

public class HelloWorldServlet extends HttpServlet {

  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
                    throws IOException, ServletException
  {
     response.setContentType("text/html");
     PrintWriter out = response.getWriter();
     out.println("");
     out.println("HelloWorldServlet");
     out.println("HelloWorldServlet");     
     out.println("");
  }
} 

To download source right-click here and "Save As...".

References


online
The Java 2 Platform Specification
Books
Core JSP by Damon Hougland and Aaron Tavistock
Core Servlets and JavaServer Pages by Marty Hall
Comments
Sign in to be the first to comment on Java Servlets.