实现Servlet 和ServletConfig接口的类

package test.atWeb;


import java.io.IOException;
import java.util.Enumeration;


import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
//自定义的一个Servlet的实现类,让实现Servlet类都继承该类。
public abstract  class myloginServlet implements Servlet,ServletConfig{
 private  ServletConfig servletConfig;
@Override
//这些是Servlet接口的实现方法
public void destroy() {

}


@Override
public ServletConfig getServletConfig() {
// TODO Auto-generated method stub
return servletConfig;
}


@Override
public String getServletInfo() {
// TODO Auto-generated method stub
return null;
}


@Override
public void init(ServletConfig arg0) throws ServletException {
this.servletConfig=arg0;
init();
}


public void init ()throws ServletException {
// TODO Auto-generated method stub
}


@Override
public abstract void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException;


@Override
//以下方法为ServletConfig接口的方法
public String getInitParameter(String arg0) {
return servletConfig.getInitParameter(arg0);
}


@Override
public Enumeration<String> getInitParameterNames() {
// TODO Auto-generated method stub
return servletConfig.getInitParameterNames();
}


@Override
public ServletContext getServletContext() {
// TODO Auto-generated method stub
return servletConfig.getServletContext();
}


@Override
public String getServletName() {
// TODO Auto-generated method stub
return servletConfig.getServletName();





}

你可能感兴趣的:(实现Servlet 和ServletConfig接口的类)