苏州中心入驻品牌大全:JAVA编译问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 21:07:52
编译时出现类似错误,怎么解决
test.java:6:软件包javax.servlet.http不存在
import javax.servlet.http.HttpServlet;

test.java:10:找不到符号
符号:类servletException
位置:类test.Test
throws ServletException,IOException

原代码如下:
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("<h1>This is a servlet test.</h1>");
out.flush();
}
}

我已配置好tomcat,也有jdk

需要配置classpath
假设tomcat的安装目录是d:\\tomcat5.5,那么就在classpath中添加d:\\tomcat5.5\\common\\lib\\servlet-api.jar;d:\\tomcat5.5\\common\\lib\\jsp-api.jar;