Greetings to the Group,
I am on page 82 of Head First and am compiling BeerExpert.
C:\MyProjects\beerV1\src\com\example\model\javac BeerExpert.java
Note: BeerExpert.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
After recompiling with javac -Xlint parameter I get:
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
brands.add("Jack Amber");
I get the same error for Red Moose, Jail Pale Ale and Gout Stout.
A BeerSelect.class file is still created but then when I go to page 84 and modify BeerSelect.java and compile it I get:
package com.example.model does not exist.
The source for BeerSelect.java is:
package com.example.web;
// version 2 of the
servlet page 84
import com.example.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 Selection 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());
}
}}
The source for BeerExpert.java is:
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");
}
else {
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return (brands);
}
}
Before I modified it as on page 84 I successfully compiled BeerSelect.java
I was able to display the Beer Selection Page then after clicking on a color and Submit Query I received a page that read Beer Selection Advice and nothing else.
I deleted both the BeerSelect and Beer Expert class files and started over recompiling them when I received the errors above.
Since successfully display the messages on the pages in the previous paragraph I have not changed any environment variables.
This is on
Tomcat 5.5.4 JDK 1.5.0
Any help greatly appreciated.
Thanks,
Jerry Bustamente