Ok, I guess I'm mistyping something here, because I keep getting an error message when I try to compile this that says,
com/wittycritics/web/BeerSelect.java:3: package com.wittycritics.model does not exist
import com.wittycritics.model.*;
^
And then it gives me a similar error anytime I try to use something from the model package. Anyways here is the code of the two files and then the directory structures.
The file that won't compile package com.wittycritics.web;
import com.wittycritics.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Seclection Advice<br>");
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.iterator();
while(it.hasNext()) {
out.print("<br>try: " + it.next());
} // end of while
} // end of method
} // end of class
The only file in the model directory - it compiles just fine package com.wittycritics.model;
import java.util.*;
public class BeerExpert {
public List getBrands(String color) {
List<String> brands = new ArrayList<String>();
if (color.equals("amber")) {
brands.add("Jack Amber");
brands.add("Red Moose");
}
else {
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return(brands);
} // end of method
} // end of class
BeerSelect.java is in: C:\MyProjects\beerV1\src\com\wittycritics\web
BeerExpert.java is in: C:\MyProjects\beerV1\src\com\wittycritics\model
BeerExpert.java compiled to: C:\MyProjects\beerV1\classes\com\wittycritics\model
but when I try to compile the BeerSelect.java file, I get the above error message.
I'm also compiling it using (I'm in directory C:\MyProjects\beerV1 when I compile it): javac -d classes src/com/wittycritics/web/BeerSelect.java
I figure something isn't typed correctly and it's just impossible for me to see it, either that or I am missing something fundamentally easy regrading how to use packages. Anyways, any help anyone can give me would be greatly appreciated.
I'm on an Windows 2000 machine with SDK version 1.5
[ June 28, 2005: Message edited by: Nicholas Carrier ]