jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ERRATA - O'Reilly's Head First Servlets and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ERRATA - O Watch "ERRATA - O New topic
Author

ERRATA - O'Reilly's Head First Servlets and JSP

Randy Carlson
Greenhorn

Joined: Nov 24, 2004
Posts: 4

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!!!


SCJP 1.4<br />OCP 6i
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
what errors have you found? more specifically, what errors have you found that would cause you to miss a question? even if you look at the errata for the book (here) you don't find much that should cause worry.

i found a few typos in the book, but i can only think of a couple of times i found anything close to a serious error in the whole book. and it sure helped me pass.
Randy Carlson
Greenhorn

Joined: Nov 24, 2004
Posts: 4
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
Senthil Kumar N
Greenhorn

Joined: Nov 30, 2004
Posts: 19
Hi Carlson
U ve compiled the code with the option -d <directory> for the packages.
Hey man u ve specify the classpath for the classes directory. Once if u tell the classpath of that classes. it will compile fine

is it okay

if u don't understand tell man . i ll help u out. Don't worry it is a good book. U ve worth on buying this man.


bye
senthil
Randy Carlson
Greenhorn

Joined: Nov 24, 2004
Posts: 4
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!!!
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
Originally posted by Randy Carlson:


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:.)




Hey Randy,

I see that you're using Windows OS (Intel platform), while Kathy is using Apple platform and Mac OS which is flavor of the UNIX OS.

Defining environment variables (CLASSPATH is one of them) is different on different OS.

In Windows you should use semicolon (;) as path delimiter, and on UNIX the colon ( is used aas path delimiter.

I don't have the book, but from your post, I could advise you to try



instead of



regards,
MZ


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
Originally posted by Randy Carlson:

but it still works.

you have to admit for a novice, this isnt too straight-forward!!!


Glad you managed to resolve the problem.

regards,
MZ
Premkumar Gopal
Greenhorn

Joined: Jun 12, 2004
Posts: 22
Randy,
The best place to refer to configure the Tomcat is either Apache's website or the Setup documentation that comes with the Tomcat. Regarding Classpath issue: Even the experts fail sometimes. Being said that, one can learn this through experience. I have read a number of books on Servlets and HF book explained in the most simplest way that one can imagine. I understand that referring to Errata to figure out whether something is correct/incorrect especailly if it is the first time is little frustrating. Believe me, this forum is always there to help. Please do note that Kathy, who is the brain behind Javaranch creation(Free Website) from America is also the co-author of HF.

Thanks


SCJP(1.4), OCP(8i) DBA, Websphere Certified Associate Developer, Websphere Certified Solution Developer, Websphere Portal Application Developer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ERRATA - O'Reilly's Head First Servlets and JSP