aspose file tools*
The moose likes Beginning Java and the fly likes Package javax.servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package javax.servlet" Watch "Package javax.servlet" New topic
Author

Package javax.servlet

Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
I wrote a simple Java program to work with Tomcat to display a simple web page. I have included the following import statements:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

The following entries are there in the Classpath variable:
c:\Sen\Java\JavaT\jdk1.5\bin; c:\Sen\Java\JavaT\jdk1.5\lib; c:\Sen\Java\JavaT\jdk1.5\; c:\Sen\Java\JavaT\jdk1.5\jre\bin\

On compiling, I get the following error:
Ch1Servlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
Ch1Servlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;

Please advise what needs to be done to resolve this.

Thanks in advance.

Sen.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
The servlet stuff is not in the jdk. You need to download the j2ee.jar (j2eesdk


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Sunny Kumar
Ranch Hand

Joined: Oct 27, 2005
Posts: 57
Alternative: As you are using Tomcat for deploying your servlet, hence to compile it you can include in your classpath: Your_TOMCAT_installation_directory\common\lib\servlet-api.jar
This should compile the servlet without any problem.
Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
By adding the jar entry in the Classpath variable worked.

Thank you.

Sen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package javax.servlet
 
Similar Threads
Import javax.awt.* statement
cannot compile servlet
compile errors
Error while compiling
javax.servlet.http.* missing?