Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HelloWorld Servlet compilation errors

 
pradeep bommakanti
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am new to work with Servlets. I wrote a small Servlet program to print "HelloWorld" but its giving compilation errors like:

package javax.servlet does not exist
package javax.servlet.http does not exist ...

I am using jdk1.3.1_08. can anyone tell me the reason[s].
Thanks in advance

- Pradeep

here is the code:

 
Abhinay Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have J2EE on your machine?
 
pradeep bommakanti
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Abhinay,
After I set the classpath [tomcat\lib\common\servlet.jar] the Servlet file compiled successfylly.
Thanks
-Pradeep
 
Kiran Sonaje
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just put your servlet.jar into your jdk's jre\lib\ext directory.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kiran Sonaje:
Just put your servlet.jar into your jdk's jre\lib\ext directory.


Bad idea! What if they want to run another container which uses a different version of the servlet API using the same JRE?
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the jar file file will be under the $TOMCAT_HOME/common/lib directory.

But the jar file name will be either servlet.jar or servlet-api.jar depending on tomcat version.

For downloading the latest servlet version or specification :

http://java.sun.com/products/servlet/download.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic