日期:2014-05-18 浏览次数:20610 次
package pack1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.GenericServlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.util.Date;
//@WebServlet("/hello")
public class test extends GenericServlet{
public void service(ServletRequest request,ServiceResponse response)
throws ServletException,IOException{
response.setContentType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head><title>欢迎光临</title></head>");
out.println("<body>");
out.println("我的第一个Servlet源程序");
out.println("<br>");
out.println(new Date());
out.println("</body>");
out.println("</html>");
out.flush();
out.close();
}
@Override
public void service(ServletRequest arg0, ServletResponse arg1)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
public class HelloWorld extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {