【Servlet学习】继承GenericServlet简单示例

 package com.sprying;
import java.io.PrintWriter;

import javax.servlet.GenericServlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
*第二种方法开发servlet,
*继承GenericServlet,只要重写Service方法
*/
public class GenericExample extends GenericServlet
{

/**
*
*/
private static final long serialVersionUID = -8315318427851675298L;

public void service(ServletRequest req,ServletResponse res)
{
try
{
PrintWriter pw=res.getWriter();
pw.print("HelloWorld,extends of GenericServlet!!!");
}catch(Exception e)
{
e.printStackTrace();
}
}
}
posted @ 2012-03-29 22:33  小方。  阅读(928)  评论(0编辑  收藏  举报