I have import stmt (like import org.apache.* etc ) on top of a servlet so I believe that I need to have those files unjarred in classes directory for servlet to compile. Now at run time do I still need jar file to run the servlet. My servlet does not compile unless I unjar and it does not run unless I put jar in lib. Sound weird. I should not be needing to do unjar whiel compile.
You're quite right: you don't need to unjar it to compile or run, but in both cases you need to make it available on the classpath.
The trick here is that the compile time and runtime classpath (for app servers) is different. If you compile from the command line you need to add the jar (and the whole jar, not just the path to the jar) to your classpath, but at runtime it will find the jar in the WEB-INF/lib directory.
You don't need to unjar anything to compile or run a servlet. You just need to have the needed jar files on your classpath.
Unlike with classes, which only need the parent directory on the classpath, jar files have to be added directly to the classpath for their contents to be accessible.