When we write a java servlet class and compile it, most of the problems occur: javax. servlet package and javax. servlet. the http package does not exist. Most of the answers on the network are as follows:
1. Copy tomcat common \ lib \ servlet. jar (or servlet-api.jar) to java \ jre \ lib \ ext
2. Copy common \ lib \ servlet. jar (or servlet-api.jar) under tomcat to jdk \ lib and add it to the environment variable classpath.
3. Directly compile with eclipse
And so on.
However, many times we have tried the above and found that the compilation is not complete. Why? I think the servlet under the tomcat directory. jar is not the package javax. servlet and javax. servlet. http, the best way is to download a javax directly to the network. servlet package, which contains javax. servlet. copy the downloaded package to jdk \ lib and configure it to the environment variable classpath (or directly download it to jdk \ lib). Try again and maybe it will be OK.
This article is from the "Midnight Hummer" blog