I am getting an error "javax.servlet package not found" when i m trying to compile the following java code
I am getting an error javax.servlet.* package not found while trying to compile the following source code :
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class servlet1 extends HttpServer
{
public void doPOST(HttpServletRequest req , HttpServletResponse res) throws ServletException,IOException
{
String uid = req.getParameter("T1");
String pwd = req.getParameter("T2");
PrintWriter pw=res.getWriter();
pw.println(uid);
pw.println(pwd);
}
}
I'm using java 6.0 and开发者_高级运维 tomcat 6.0 softwares
Please tell me what should I do for successfully compiling this file?
When you add servlet.jar or j2ee.jar to your classpath you will have to fix the doPost signature. It should be doPost, not doPOST
You need the Java EE Jars in your Classpath. You can find them in the lib-directory of your app-server (tomcat, glassfish etc.)
http://download.oracle.com/javaee/6/api/overview-summary.html
精彩评论