• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.servlet cannot find package?

 
Peter Shipway
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What J2EE server are you running on?
 
Peter Shipway
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is there a . (dot) before C:\Java\lib\servlet.jar
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error you're getting and when is it happening?
 
siva kumar adabala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic