package it.cast.servlet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class ServletDemo1 extends HttpServlet { /* public void destroy() {
System.out.println("如果存在这个销毁,则hello servlet就没法显示。。。");
}*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getOutputStream().write("hello servlet".getBytes());
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { doGet(request, response);
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
} }
如果web应用没有部署,就不会servlet生成的webroot新增到tomcat的webapps中。则使用浏览器是没办法找到文件的。