aspose file tools*
The moose likes Servlets and the fly likes javax.servlet cannot find package? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "javax.servlet cannot find package?" Watch "javax.servlet cannot find package?" New topic
Author

javax.servlet cannot find package?

Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
Hey yo,

I cant seem to sucesfully import the package mentioned in subject line for servlets, I have just freshly instaled J2EE 1.4 SDK and correctly setup JCreator yet I still cant seem to get it working. Did I install the wrong package? Or is there a step I have missed?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

What J2EE server are you running on?


My Blog: Down Home Country Coding with Scott Selikoff
Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
I am not sure, how can I tell? I downloaded the one from this page http://java.sun.com/j2ee/1.4/download.html the one that says "Full Bundle"

I hope this helps.

Now I think about it, this is a compile error not really a server error I have locted the missing package (servlet.jar) and included it in my classpath, however still it is giving me errors. Is this the correct format of classpaths?

;.C:\Java\lib\servlet.jar
[ November 02, 2005: Message edited by: Peter Shipway ]
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
why is there a . (dot) before C:\Java\lib\servlet.jar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What is the error you're getting and when is it happening?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
siva kumar adabala
Greenhorn

Joined: Nov 03, 2005
Posts: 2
hello guy,


depending upon the server we have to set servlet.jar file to the classpath.

I am assuming u r using Tomcat in "C" drive.

set the classpath as follows:

set CLASSPATH=.;C:\tomcat\common\lib\servlet.jar;


and path should indicate jdk's bin directory

set path=.;c:\jdk\bin;

now u will not get any problems.


otherwise it would be better to take the servlet.jar file and place it into jdk's lib directory.
now set the CLASSPATH

set CLASSPATH=.;C:\jdk\lib\servlet.jar;

-siva
[ November 03, 2005: Message edited by: siva kumar adabala ]
Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
The error I get is:

--------------------Configuration: MutilDataServlet - JDK version <Default> - <Default>--------------------
D:\Uni\Java\Examples\MutilDataServlet\MutilDataServetClient.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
D:\Uni\Java\Examples\MutilDataServlet\MutilDataServetClient.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
D:\Uni\Java\Examples\MutilDataServlet\MutilDataServetClient.java:7: cannot find symbol
symbol: class HttpServlet
public class MutilDataServetClient extends HttpServlet{
^
3 errors

Process completed.

The servlet.jar file is in with the other libary files in java/lib this is all very confusing what am I doing wrong? I changed the classpath to include ; at the end and still no result. Thanks for all the help so far everyone, hopefully I cacn work this out I am really interested in the use of servlets with connecting to databases and its a shame that I cant learn
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is a section in the JIG Beginner FAQ on setting up the classpath.
The servlet faq has a 'wrapper' entry which explains the servlet specific issues.

http://faq.javaranch.com/view?CompilingServlets

It should get you past this.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: javax.servlet cannot find package?