リスト1:サーブレット版“Hello world”プログラム(HelloSv.java)


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

public class HelloSv extends HttpServlet {
  public void service( HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException {
    res.setContentType( "text/html; charset=Shift_JIS" );
    PrintWriter out = res.getWriter;
    out.println( "<HTML>" );
    out.println( " <BODY>" );
    out.println( " Hello Servlet world!<BR>" );
    out.println( " </BODY>" );
    out.println( "</HTML>" );
  }
}


本文へ戻る