This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

servlet compiling errors

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am following an exercise from HFJS and encounter compile errors.

I have two servlet files named and

I create a development like this:
--------------------------model (
--------------------------web (


1) I compiled from command prompt:

c:\myprojects\beerv1> javac -classpath "c:\program files\tomcat 5.0\common\lib\servlet-api.jar:classes: ." -d classes src\com\example\model\

it created BeerExpert.class successfully in c:\myprojects\beerV1\classes\com\example\model

2) When compiled

c:\myprojects\beerv1> javac -classpath "c:\program files\tomcat 5.0\common\lib\servlet-api.jar:classes: ." -d classes src\com\example\web\

I got 11 errors.

The error message indicates, such as:
src\com\example\web\ package com.example.model does not exist"
import com.example.model.*;
src\com\example\web\ package javax.servlet does not exist"
and so on...




package com.example.web;

import com.example.model.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class BeerSelect extends HttpServlet
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice <br>");
String c = request.getParameter("color");

/* instantiate the BeerExpert class and call getBrands() */

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.Iterator();
while (it.hasNext()){
out.print("<br>try: " +;




package com.example.model;

import java.util.*;

public class BeerExpert{

public List getBrands(String color){

List brands = new ArrayList();
if (color.equals("amber")){

brands.add("Jack Amber");
brands.add("Red Moose");


brands.add("Jail Pale Ale");
brands.add("Gout Stout");


Posts: 43016
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Windows, the character that separates classpath entries is not ":", but ";". So the classpath should read

Also make sure it doesn't contain any extra spaces, like the one that you had after "classes:".
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic