I use JDK 1.4.1_02 and Tomcat5.0 under Window2000 Server,
I have a Servlet file,like follows:
import javax.servlet.*;
import javax.servlet.http.*; import java.io.*; public class a1 extends HttpServlet{ public void doGet(HttpServletResponse req,HttpServletResponse resp) throws ServletException,IOException{ PrintWriter pw=resp.getWriter(); pw.println("<html><body>Hello World!</body></html>"); pw.close(); } } but when I compile it,it raises many errors:
a1.java:1: package javax.servlet does not exist
import javax.servlet.*; ^ a1.java:2: package javax.servlet.http does not exist import javax.servlet.http.*; ^ a1.java:4: cannot resolve symbol symbol : class HttpServlet location: class a1 public class a1 extends HttpServlet{ ^ a1.java:5: cannot resolve symbol symbol : class HttpServletResponse location: class a1 public void doGet(HttpServletResponse req,HttpServletResponse resp) thro ws ServletException,IOException{ ^ a1.java:5: cannot resolve symbol symbol : class HttpServletResponse location: class a1 public void doGet(HttpServletResponse req,HttpServletResponse resp) thro ws ServletException,IOException{ ^ a1.java:5: cannot resolve symbol symbol : class ServletException location: class a1 public void doGet(HttpServletResponse req,HttpServletResponse resp) thro ws ServletException,IOException{ ^
6 errors I know Java not found package javax.servlet, I remember there
is a file "servlet.jar"
in Tomcat4 and I guess to put it in java
directory,but Tomcat5 didn't have this file.
How do I to solve this problem?
Thanks in advance!
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
|
- Re: Can't compile Servlet file Edward King
- Re: Can't compile Servlet file Carmine Montella