doGet()方法里调用其他方法的问题
package web1Pac;
import
java.io.IOException;
import javax.servlet.ServletConfig;
import
javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet
{ private static final long serialVersionUID = 1L;
private static final int doGetCount=0;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException { response.setContentType("text/html;charset=utf-8");
PrintWriter out;
out=response.getWriter();
out.print("会家了");
System.out.println("doGetCount method called"+doGetCount+"times");
processRequest(request,response);
}
public void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{ PrintWriter out;
String title="Servlet Life Cycle Demo Page";
int iniCount=0;
int calledCount=0;
int destryCount=0;
String heading1="Init times"+iniCount;
String heading2="Called times"+calledCount;
String heading3="Destroy times"+destryCount;
response.setContentType("text/html;charset=utf-8");
out=response.getWriter();
out.print("<html><head><title>"+title+"<title>");
out.print("<head><body>");
out.print("<h1>"+heading1+"</h1>");
out.print("<h1>"+heading2+"</h1>");
out.print("<h1>"+heading3+"</h1>");
out.print("</body></html>");
out.close();
}
}
上面的程序使用的springsource软件编译的,启动服务器后,一会服务器端就会有输出doGetCount的值,而浏览器端却是空白,在doGet()中
调用自定义的processRequest(request,response)方法为什么没有用???怎样改才能够确保processRequest(request,response)调用了??
------解决方案--------------------
out.print("会家了");这句话就已经返回客户端了,所以没有用