What is the HelloWorld Servlet?

Alex Chaffee

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

public class HelloHttpServlet extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse res)
 	throws IOException, ServletException
 		String name = req.getParameter("name");
 		if (name == null) name = "Joe";
 		ServletOutputStream out = res.getOutputStream();
		out.println("Hello, " + name + "!");
This code responds to an invocation of the form

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.