Servlets in Eclipse
Compile them just like any other piece of java code. Compilers know nothing of servlets. Now, launching a servlet container for your compiled code....that's another discussion.
yes...so how do i do it? it cannot resolve javax.servlet when i compile.
You need to add the jar containing HttpServlet, etc. to your classpath. Usually, people compile against the HttpServlet class in a jar provided by the maker of their servlet container. For example, my Eclipse workspace contains a reference to weblogic.jar because I deploy to Weblogic. If you are using something else (say, Tomcat), you'll have to figure out what the appropriate jar from their distribution is. Sun might provide a generic implmentation of the servlet base classes for compilation purposes, but I don't know much about that.
If you have the Sun J2EE SDK installed, there should be a library called "servlet.jar" which is included with that. That should contain all of the javax.servlet packages. Add that to your classpath and you should be in good shape.
It's not required, but I've been happy with MyEclipse:
Fog Creek Home