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

Cannot compile servlet

 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
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?
Thanks,

Terry Doyle
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup.
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 java.io.* 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.
 
Johannes de Jong
tumbleweed
Bartender
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Terence see Servlets and JavaServer Pages (JSP) 1.0: A Tutorial
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thank you both for your quick answers.
Tim:
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.
JDJ:
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic