File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Cannot compile servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot compile servlet" Watch "Cannot compile servlet" New topic

Cannot compile servlet

Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
I'm just starting on JSP and Servlets and I have the JSWDK-1.0 installed and running (it was very easy to set up).
I have no difficulties running JSP's with includes, directives expressions, etc.
However when I tried to compile this example servlet from a web tutorial

I get 6 errors because the import statements don't seem to work.
Any ideas?

Terry Doyle

Raising Flares debut album 'Ignition' out now

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

1. Are you really trying to compile them the servlet - i.e. use the "Javac" command? Or are you thinking that they work the same way that JSPs do? They don't. Think of them as Java Applications.
2. Assuming you're compiling properly, do you have the CLASSPATH set up properly? You didn't mention which imports were failing, but if* is OK and the javax.servlet imports fail, it's because your classpath for javac doesn't include the servlet.jar file from your JSWDK distribution.

An IDE is no substitute for an Intelligent Developer.
Johannes de Jong

Joined: Jan 27, 2001
Posts: 5089
HI Terence see Servlets and JavaServer Pages (JSP) 1.0: A Tutorial
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Thank you both for your quick answers.
Yes I'm using the javac command - I got that far
The class path was the trouble. When following the instructions in the faq I put the servlet.jar in but with the JDK path not the JSWDK path.
I set that right and now it compiles fine.
Guess where I got the example code??? Yes. I have just started that tutorial.

Thanks again to both of you.

Terry Doyle
[This message has been edited by Terence Doyle (edited September 11, 2001).]
I agree. Here's the link:
subject: Cannot compile servlet
It's not a secret anymore!