程序手记

程序是我毕生的追求......
随笔 - 19, 文章 - 0, 评论 - 9, 引用 - 0
数据加载中……

JAVA WEB开发 (First Servlet Samlet Code) 第四天

HelloServlet.java

package tw.com.javaworld.CH2;

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

public class HelloServlet extends HttpServlet{
    //Initialize global variables
    public void init(ServletConfig config) throws ServletException{
        super.init(config);
    }
    
    //Process the HTTP Get request
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=GB2312");
        PrintWrite out = response.getWrite();
        out.println("<html>");
        out.println("<body>");
        out.println("Hello World<br>");
        out.println("大家好");
        out.println("</body>");
        out.println("</html>");
        out.close();
    }

    //Get Servlet information
    public String getServletInfo(){
        return "tw.com.javaworld.CH2.HelloServlet Information";
    }
}

posted on 2008-08-04 18:15 程序手记 阅读(233) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: