我创建了一个 java servlet 程序名称FirstServlet。
我把它放在Tomcat 7.0\webapps\ROOT\WEB-INF\classes\FirstServlet.java并且我设置了servlet-api.jar的类路径但是当我编译它时
我发现了一些错误。
代码是:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FirstServlet extends HttpServlet {
// Runs when the servlet is loaded onto the server.
public void init() {
//......
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// Set the MIME type for the response message
response.setContentType("text/html");
// Write to network
PrintWriter out = response.getWriter();
// Your servlet's logic here
out.println("<html>");
out.println(" ...... ");
out.println("</html>");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// do the same thing as HTTP GET request
doGet(request, response);
}
public void destroy() {
// ......
}
}
错误是: