• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!!!
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Mikalai Zaikin
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic