How to compile a servlet?
Hi,
There is a piece of servlet like this:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SimpleServlet extends Httpservlet{
public void init() throws ServletException{ }
public void doGet(HttpservletRequest req,HttpServletResponse resp)
throws ServletException,IOException{
PrintWriter out=resp.getWriter();
resp.setContentType("text/html");
out.println("<html>");
//...
out.println("</html>");
out.flush();
}
public void doPost(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException{
doGet(req,resp);
}
public void destroy(){ }
}
But when I compile it in command line:
< javac SimpleServlet.java >
it shows:
SimpleServlet.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
SimpleServlet.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
SimpleServlet.java:7: cannot resolve symbol
symbol : class Httpservlet
symbol : class ServletException
symbol : class HttpservletRequest
...
It seems that the package 'javax.servlet' and its classes do not exist in J2sdk,J2ee.
Where is the package? How can I compile the sevlet?
My System is Windows XP and the platform is j2EE1.4 Whith j2sdk1.4.2.
By the way,my 'javac' works well when compile other j2se program using 'javax'package.
thanks,
wujie
|