|
Test.java源代码如下:
package test;
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 Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("<html><body><h1>This is a servlet test.</h1></body></html>");
out.flush();
}
}
编译错误如下:
E:\tomdep\WEB-INF\classes\test>javac Test.java
Test.java:4: package javax.servlet does not exist
import javax.servlet.ServletException;
^
Test.java:5: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
Test.java:6: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
Test.java:7: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
Test.java:8: cannot resolve symbol
symbol : class HttpServlet
location: class test.Test
public class Test extends HttpServlet {
^
Test.java:9: cannot resolve symbol
symbol : class HttpServletRequest
location: class test.Test
protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
Test.java:9: cannot resolve symbol
symbol : class HttpServletResponse
location: class test.Test
protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
Test.java:10: cannot resolve symbol
symbol : class ServletException
location: class test.Test
throws ServletException, IOException {
^
8 errors
E:\tomdep\WEB-INF\classes\test> |
|