HelloBeijing.java
package com;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloBeijing extends HttpServlet
{ public void init (ServletConfig config) throws ServletException
{ super.init(config); /*创建一个servlet对象config,config并调用init()方法初始化*/
}
public void service (HttpServletRequest request,HttpServletResponse response)throws IOException
{response.setContentType("text/html;charset=gbk");//设置相应的mike类型
PrintWriter out=response.getWriter();//获取一个想客户发送数据的输出流
out.println("<html><body>");
out.println("<h2>北京奥运圆满成功!</h2>");
out.println("</body></html>");
}
}
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<servlet>
<servlet-name>hello </servlet-name>
<servlet-class>com.HelloBeijing</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello </servlet-name>
<url-pattern>/lookHello</url-pattern>
</servlet-mapping>
</web-app>
posted on 2009-05-12 10:12
鹏凌 阅读(125)
评论(0) 编辑 收藏 所属分类:
Java --j2ee