Question:
Package javax.servlet, javax.servlet.http does not exist?
anonymous
2013-03-21 14:57:52 UTC
I'm trying to compile a servlet and it keeps telling me javax.servlet does not exist.
Though I set the classpath correctly
https://lh5.googleusercontent.com/itZkNymvvP5P74MAcL7RP2Jmg-yBcUuJ4nH6LzsiQRxksPaWcnK2qMSlmVCges7Ilw=w1600
that should be a photo of what it looks like now
Here is my full classpath
Files\Java\jdk1.7.0_13\bin;
C:\apache-tomcat-7.0.35\common\
lib\servlet-api.jar;c:\.
Four answers:
anonymous
2013-03-21 15:28:55 UTC
The servlet-api.jar file is part of the Java Servlet runtime environmnet for Tomcat - it's not a developer library it's intended for compiled Java code to be used at run-time.



In your question you said "Files\Java\jdk1.7.0_13\bin" was in your path variable, that means you must be using Java SE because the latest version of Java EE is version 6 update 4. There is no version 1.7 of Java EE.



Servlet is part of the Java EE JDK it is not included in the Java SE JDK. Are you sure you installed the Java EE JDK? This one [1]



Edit: Well then with all due respect to your teacher he must be an idiot or a troll.



You can view the Java API documentation for Java SE here [2] you will find there is no javax.servlet package in Java SE. If you view the Java API documentation for Java EE here [3] you will see the javax.servlet package [4]



Any Java SE program referencing the javax.servlet package will fail to compile because the package does not exist in SE.
Jim Maryland
2013-03-21 15:09:06 UTC
Gotta be a class path issue (sorry, don't trust the site so didn't review the link). I've run into this before in an IDE where the context aware editor would pick it up for code entry but compilation wouldn't be aware of it. Take a look at some of the help documents for your IDE or check that the classpath (if using command line or a build environment like Ant, Maven, etc...) includes the jar libs correctly.
anonymous
2016-03-08 11:07:23 UTC
Yes, they are still there. Canada...the Country that gave us Terrance and Phillip, funny bacon, cheap medicine, and Michael J. Fox. Go north until you see a pretty white flag with a red leaf on it blowing in the cold breeze. They are a polite people who readily accept packages. They say "eh?" a lot. They also say "aboot and battrey" instead of "about and battery". Canadians get a bad rap: "Blame Canada, Blame Canada Because when Canada is gone, There'll be no more Celine Dion Blame Canada, Blame Canada They're not even a real country anyway". But in reality, they are a nice bunch of folks.
Natarajan
2014-03-24 01:16:17 UTC
to know about how to run servlet watch


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...