Inside the eclipse, the compiler uses server-side run-time frames to get these definitions.
In Ant you need to add the appropriate jar files.
For example, you can use servlet-api.jar from the Apache Tomcat lib directory. This does not mean that you can only deploy against tomcat, you should be able to deploy to any application server that implements the same version of the servlet API.
source share