Your code is absoultely correct and it is working fine on my machine , it is bettet try using a new javax.servlet.jar. Their may be problem with that otherwise it is working fine and not giving any compilation errors .
Thanks for your response. Please let me know which application server you are using to deploy this servlet. I am using JBoss-3.2.3 (latest version). I tried using javax.servlet.jar (in classpath) but facing the same problem.
Once you make it working , please keep this JAR file in web-inf/lib folder of your application, so that you will not have these problems when you deploy this application in other environment or in same environment with different versions of servlet.jar file.
I am also using the same application server with eclipse as development tool, if you are using the same enviornment , the javax.servlet.jar should be there in your in jboss, in your project classpath and also in your project. check these things