• public void init(ServletConfig config) throws ServletException
• public void service(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
• public void destroy()
• public ServletConfig getServletConfig()
• public java.lang.String getServletInfo()
Listing 2.1.PrimitiveServlet.java
import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;
public class PrimitiveServlet implements Servlet {
public void init(ServletConfig config) throws ServletException {
System.out.println("init");
}
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
System.out.println("from service");
PrintWriter out = response.getWriter();
out.println("Hello.Roses are red.");
out.print("Violets are blue.");
}
public void destroy() {
System.out.println("destroy");
}
public String getServletInfo() {
return null;
}
public ServletConfig getServletConfig() {
return null;
}
}
petrel ,java 爱好者,在深圳从事 java 和数据库的开发工作,喜爱各项运动!可以通过petrel.zhang@ccjk.com 与她联系.也可以点击http://www.matrix.org.cn/user_view.asp?username=petrel查看她的信息.进入讨论组讨论。
(出处:http://www.VeVb.com)
新闻热点
疑难解答