Randy Carlson

Greenhorn
+ Follow
since Nov 24, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Randy Carlson

Got it. i set the CLASSPATH var to be

c:\tomcat\common\lib\servlet-api.jar;c:\java\MyProjects\beerV1\src\

now when i issue to javac command it looks like such

>javac -d classes src/com/example/model/BeerExpert.java
>javac -d classes src/com/example/web/BeerSelect.java

I get some other note:
Note: Recompile with -Xlint:unchecked for details.

but it still works.

you have to admit for a novice, this isnt too straight-forward!!!
Too many to list. Check out the errata page. I think that is a lot personally. I have been stuck on pages 84-85 of the book for over 2 days now. I am even working with someone who originally tested the very first Sun release and he cant figure it out.

If you can solve my problem, i will take back my earlier comments. It shouldnt be this hard. I was an old Microsoft geek, and want to learn Java, but I've never had this much difficultly installing and compiling. For starters, jdk1.4 doesnt run with tomcat 5 out fo the box.

Here is where i am currently stuck.
I am trying to compile the BeerSelect servlet after adding the line
import com.example.model.*;

First off the command line compile does not work as the book says. I had to change ....servlet-api.jar:classes:. to .....servlet-api.jar (no classes:.)

Here is my code (just as the book says) and error:
.....
package com.example.web;

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());
}
}
}


here is the error i get:
C:\java\MyProjects\beerV1\src\com\example\web>javac -classpath C:/tomcat/common/lib/servelt-api.jar -d classes src/com/example/web/BeerSelect.java
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
BeerSelect.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
BeerSelect.java:9: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
BeerSelect.java:11: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,
^
BeerSelect.java:12: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
HttpServletResponse response) throws IOException, Servlet
Exception {
^
BeerSelect.java:12: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
HttpServletResponse response) throws IOException, Servlet
Exception {
^
BeerSelect.java:19: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:19: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
9 errors

......

Maybe i am doing something wrong, but i cant for the life of me figure it out.


Thanks,
Randy

Just thought i would let everyone know how horrible this book is. I like the format, but there are so many errors in the book, it doesnt even pay to try the examples. So for i am on Chapter 3 and there have been errors in all 3 chapter examples. I HATED O'Reilly books before, and hate them even more now. What a complete waste of money.

"Hey, lets write a book, have tons of errors in it, then charge people to buy it".

"Yeah sounds good. It's the American way. Create some crappy product, then charge money for it.

In short, do not buy this book, unless you like getting frusterated and like to constantly toggle between your code and the Errata page at O'Reilly!!!
Are there any other books published for the new test 310-081 besides the Head First book? I have always liked the style and formatting of wrox and sybex books?

I need to buy a book soon, but i dont want to rush and buy the wrong one.

Thanks,
Randy