This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hebert Coelho wrote:If am not mistake, you will need the j2se and tomcat. [=
i have that
but still the code which has import like
is not compilling and message is
this package does not exits even though i have manually seen the api there is no such package called javax.servlet in standard j2se
where as this is the same problem in netbeans while creating j2se apps you will not see any package like javax.servlet and while creating
web application in netbeans we can use javax.servlet ?
so thats why i wanted to know , do i need j2ee sdk to complile servlet code or j2se is enough ?
That package is not part of JSE, but it comes with Tomcat; look in the TOMCAT_HOME/lib directory for a file called servlet-api.jar. You need to include that in all classpaths you intend to use with servlets.
Tomcat includes an implementation the Servlet API from the Java EE. You need to include the servlet API JAR file from Tomcat in your classpath to resolve classes in the javax.servlet package.
See the Tomcat Application Developer's Guide for some helpful information on coding for Tomcat.
Tim Moores wrote:That package is not part of JSE, but it comes with Tomcat; look in the TOMCAT_HOME/lib directory for a file called servlet-api.jar. You need to include that in all classpaths you intend to use with servlets.
You need to enclose the entire class path, as well as the file path, in double quotes:
C:\Users\Admin>javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;" "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\beerV1\src\com\example\web\BeerSelect.java". If you don't then the command prompt will see the spaces as separators for different arguments. The arguments to javac then become:
* Foundation\Tomcat 6.0\lib\servlet-api.jar;
* Foundation\Tomcat 6.0\webapps\beerV1\src\com\example\web\BeerSelect.java
The quotes will cause everything between them to be seen as one single argument:
* C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;
* C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\beerV1\src\com\example\web\BeerSelect.java