philip.matheson (5) [Avatar] Offline
#1
Are you gonna put it all together?
It’s just so inconvenient to search for Errata mixed up with all the other forum messages...

Here is my contribution:

1 – Chapter 3 (Web application and HTTP basics), Section 3.2.2 (The structure of an HTTP request), Page 25, first paragraph:

“…HTTP 1.1 requests can have only one of the following three methods: GET, HEAD or POST. HTTP 1.1 adds five more: PUT, OPTIONS, DELETE, TRACE and CONNECT.”

The correct form should be:

“…HTTP 1.0 requests can have only one of the following three methods: GET, HEAD or POST. HTTP 1.1 adds five more: PUT, OPTIONS, DELETE, TRACE and CONNECT.”

2 – Appendix C (Review Q & A), Chapter 4 (The servlet model), Question 7, Page 415:

“Answers: b and e”

The correct pair of answers is c and e:

c getHeader() of HttpServletRequest
e getHeaders() of HttpServletRequest
PapaLazarou (4) [Avatar] Offline
#2
Re: 2nd Edition Errata
Noticed these myself but I disagree with your second correction. There is only (strictly speaking) one correct answer...

e)

a) b) and d) are all wrong due to headers being no part of ServletRequest. So the author's are wrong here in saying b).
However, c) is also wrong as there is no getHeader() method in HttpServletRequest, there is a getHeader(String headerName) but that is obviously not the same thing.

Mike
philip.matheson (5) [Avatar] Offline
#3
Re: 2nd Edition Errata
You're right Mike!

...But have you also noticed that many methods through out the book - examples, exercises, answers etc - don't present stuff like the parameters, the return type and the thrown exceptions?

Thank you,

Philip.
PapaLazarou (4) [Avatar] Offline
#4
Re: 2nd Edition Errata
I agree Philip smilie

Maybe it's a convention when only talking about existence of methods. But it's a poor convention if that's the case. Omitting return types, parameters and exceptions is a pretty poor way of educating people. I do hope that some work goes into getting the errata updated!

Regards,

Mike
galex (1) [Avatar] Offline
#5
Re: 2nd Edition Errata
Hello

Also on errata
page 127-128 about the "Will not work example" and the explanation for it.

I will copy/paste from the Servlet 2.4 specs:

"SRV.1.6.1 HttpSessionListener.sessionDestroyed
In the previous versions of the specification, this method was defined as:
Notification that a session was invalidated.
As of Version 2.4, this method is changed to:
1. Please see the JavaTM 2 Platform, Enterprise Edition specification available
at http://java.sun.com/j2ee/
OVERVIEW
Final Version
22
Notification that a session is about to be invalidated
so that it notifies before the session invalidation. If the code assumed the previous
behavior, it must be modified to match the new behavior."


As you can see it is quite different from their explanation.

Kind regards
Alex
jeoffrey (1) [Avatar] Offline
#6
Re: 2nd Edition Errata
Chapter 14 (Using JavaBeans) Section 14.7 (Review Questions)

Questions 1, 3, 4, 5, 6, 7, 8, 9 and 12 use the fully qualified class chapter14.AddressBean in the code examples.

Appendig C (The review Q & A), Chapter 14 (Using JavaBeans) use only the class name AddressBean in the code examples.

Chapter 14 (Using JavaBeans) Section 14.7 (Review Questions), Page 284, Question 11

The given code example will give translation-time errors.
To fix this, the line
<jsp:useBean id="chapter14.address" class="AddressBean" />
should be changed to
<jsp:useBean id="address" class="chapter14.AddressBean" />
smendez (4) [Avatar] Offline
#7
Re: 2nd Edition Errata
touché:
the correct answer is : f no one of the obove
why:
servlet API Doc
Interface HttpServletRequest
method summary
...
java.lang.String getHeader(java.lang.String name)
Returns the value of the specified request header as a String.
...
java.lang.Enumeration getHeaders(java.lang.String name)
Returns all the values of the specified request header as
an Enumeration of String objects.
pace
sergio
smendez (4) [Avatar] Offline
#8
Re: 2nd Edition Errata
Hi deshmukh/Malavia/Scarpino,

quote
Are you gonna put it all together?
It’s just so inconvenient to search for Errata mixed up with all the other forum messages...
Here is my contribution:
quote

quote Nr. 1
deshmukh et al, 2th edition SCWCD, page 89
6.3.3 javax.sevlet.Http.HttpServletRequestListener
quote Nr. 1
==>error: inexistent class

quote Nr. 2
deshmukh et al, 2th edition SCWCD, page 122, Listing 8.1:
public void doPost(HttpServletRequest req, HttpServletResponse res) {
quote Nr. 2
==> public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
==>error: wrong doPost() signature

quote Nr. 3
deshmukh et al, 2th edition SCWCD, page 124, Quizlet code:
public void doGet(HttpServletRequest req, HttpServletResponse res) {
quote Nr. 3
==> public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
==>error: wrong doGet() signature

quote Nr. 4
deshmukh et al, 2th edition SCWCD, page 91, Quizlet:
Q: You have written a class named MyServletRequestListener to listen for
servletRequestEvents. How will you configure this class in the deployement
descriptor?
A: ...(only the code)
<web-app>
...
<listener>
<listener-class>MySessionAttributeListener</listener-class>
</listener>
...
</web-app>
quote Nr. 4
==>error: <web-app> signature wrong (servlet_2_4-fr.spec, SRV.13.3)
==>error: <listener-class> wrong (trivial!)

quote Nr. 5
deshmukh et al, 2th edition SCWCD, page 210 , trivial error
Table 11.5
getAttributeNamesIn Scope(int scope)
quote Nr. 5
==>error: trivial error/right: getAttributeNamesInScope(int scope)

quote Nr. 6
deshmukh et al, 2th edition SCWCD, page 170 and 171
page 170: Tables 10.2 and 10.3 contain some examples of valid and invalid JSP expressions
based on the following declarations:
Table 10.2
...
<%! ... <br /> Float aFloatobj = new Float(12.6);
...
char getChar() {return 'A';}
%>
Table 10.3
...
...
<%= aFloatObject %> explanation: A method returning a float (uuups?)
<%= aVector %> explanation: a variable referring to a Vector object
...
quote Nr. 6
==> aFloatObject is a FLOAT, why a method returning a float??? smilie-)
==>error: undefined variable aVector

quote: Nr 7
deshmukh et al, 2th edition SCWCD, page 308 and 460
page 308:
13. Which tags can be found in a JSTL choose? (select two)
a case
b choose
c check
d when
e otherwise
page 460
the same question
a case
b select
c check
d when
e otherwise
quote: Nr 7
error==> answers page 308b != answers page 460c

quote Nr 8
deshmukh et al, 2th edition SCWCD, page 373 and 467
page 373, question 4
If placed inside the body of a simple tag, which ...
page 467, question 4
If placed inside the body of a custom tag, which ...
quote Nr 8
error==> question page 373 != question page 467
error==> answers to question page 373 != answers to qustion page 467
---------------------
sergio
Human errors can only be avoided if on can avoid the use of humans
(D. Parnas)
PapaLazarou (4) [Avatar] Offline
#9
Re: 2nd Edition Errata
Correct. For some inexplicable reason, my IDE told me there was a getHeaders() method. However having checked the spec, you're spot on! Answer (f) it is then smilie
KurtDB (10) [Avatar] Offline
#10
Re: 2nd Edition Errata
On page 36 it says "Both ServletRequest and its subclass, HttpServletRequest..."

Given the fact that both ServletRequest and HttpServletRequest are interfaces, I assume it should say subinterface in stead of subclass? smilie
drnickmsn (3) [Avatar] Offline
#11
Re: 2nd Edition Errata
Hi all,
Since this forum seems to be a good place for listing errata, I have one.

On page 118, Section 7 Review Question 2:
The first line of the code has an extra comma between the ServletResponse class identifier and variable name:
"public void doFilter(ServletRequest req, ServletResponse, res,"

This error is repeated on page 425 in the listing of the answers to the Review Questions.

Please add this to your list.

Mark Nelson
cawel (4) [Avatar] Offline
#12
Re: 2nd Edition Errata
> As of Version 2.4, this method is changed to:
> [...]
> so that it notifies before the session
> invalidation.

I do agree with you Alex. The meaning of the SessionDestroyed() method of the HttpSessionListener has changed with the Servlet 2.4 spec. And this implies that the Listing 8.4 (p. 127) would actually work.


In addition to that, I've noticed another error, this time in the review questions of the same chapter.

In the review questions of chapter 8, I would say the answer provided for question #7 is incomplete/unclear.

By that I mean that if I would have this question on the exam, I wouldn't know what to answer, as 3 answers are correct, and the question asks to select only one.

Although it says the answer is c, the answer b is also valid. The question does not require to provide all the possibilities for having a session that never expires. Indeed, even the answer c does not provide all of them, as a timeout of -4 in the deployment descriptor would also work for example. Therefore, answers b and c are both correct.

One could also argue that answer e is correct, as it would also work. Although this is probably not the best way to do it.

Feel free to comment on this!

/Cawel
drnickmsn (3) [Avatar] Offline
#13
Re: 2nd Edition Errata
Page 231: The question at the top of the page is "What is wrong with the following JSP document?"
I believe that the first line of the JSP code is missing quotations around the "http://java.sun.com/JSP/Page", as in:
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">

Mark Nelson
drnickmsn (3) [Avatar] Offline
#14
Re: 2nd Edition Errata
Page 249 Chapter 13 Review Question 1:
Shouldn't the answer be c?
From the available code segment, variable a is undeclared and undefined. Does it have a default data type and value? If so, that should be explained in the answer. How is (5 + 3 + a > 0)?

Mark Nelson
cawel (4) [Avatar] Offline
#15
Re: 2nd Edition Errata
Go back to the bottom of p. 242, you'll have interesting examples.


> data type and value? If so, that should be explained
> in the answer. How is (5 + 3 + a > 0)?

To my understanding, here a is not a String (otherwise it would have been "a"), but it is undefined, so its value is actually 0.

So (5 + 3 + a > 0) is actually evaluated as (5 + 3 + 0 > 0). More simplified, 8 > 0, true.

/Cawel
helmers (7) [Avatar] Offline
#16
Re: 2nd Edition Errata
I completely agree with cawel in his (her?) posting "Errata proposal (50+ errors)". I think that chapter 13 is a very poor chapter and you shouldn't rely on it. I would just skip it and read the appropriate sections in the JSP specification because there are a lot of rules on type conversion and operators, of which you will need at least a basic understanding to be able to explain why certain expression or operators behave the way they do...

As for the equation (5 + 3 + a > 0): It is equivalent to evaluating (8 + a) where a is an unknown variable. Unfortunately the book doesn't attempt at all to clarify this seemingly simple example.
But when I try to really understand it, it turns out that I have to grab together quite a lot of rules from the official JSP specification to find out how it works...

JSP 2.0 Specification

JSP.2.5 Named Variables
... For example: ${product}
This expression will look for the attribute named product, searching the page,
request, session, and application scopes, and will return its value. If the attribute is
not found, null is returned.
Note that an identifier that matches one of the implicit objects described in the
next section will return that implicit object instead of an attribute value.

==> The VariableResolver makes that (8 + a) becomes (8 + null)

JSP.2.3.5.1 Binary operators - A {+,-,*} B
...
Otherwise coerce both A and B to Long and apply operator
...

==> So we have to coerce 8 and null to Longs.

JSP.2.8.1 To Coerce a Value X to Type Y
If X is of a primitive type, Let X’ be the equivalent “boxed form” of X.
Otherwise, Let X’ be the same as X.
...

==> So 8 becomes new Long(smilie and null stays null (? in JSP 2.8.1 it is not explained what to do when Y is null ?)

JSP.2.8.3 Coerce A to Number type N
If A is null or "", return 0.
...
If N is Long, return new Long(A.longValue())
...

==> So new Long(smilie stays new Long(smilie and null becomes new Long(0)

JSP.2.3.5.1 said that we have to apply the operator to the two Longs 0 and 8.
==> So (8 + null) becomes (8 + 0) = 8



Indeed, as far as I can see from the JSP specs, null (or any variable that cannot be resolved by the VariableResolver) always takes the default value of the expected type.
So if null occurs in an operation with integers, it becomes 0.
Also, (a ? "exists" : "not_exists") returns "not_exists" if a is not available.
etcetera...

> From the available code segment, variable a is undeclared and undefined.
> Does it have a default data type and value?
> If so, that should be explained in the answer.

It's not only the answer that should explain something.
It's the whole chapter that should explain that there is a variable resolver, that there are strict coercion rules, etcetera etcetera...
ginkgo (4) [Avatar] Offline
#17
Re: 2nd Edition Errata
I got a little errata in Chapter 17 Page 356
below is the detail
---------------------------------------------
step 2 line 1
the book said invoke the setBody() to make it available fot java class.
The setBody() SHOULD be setJspBody()

-----------------------------------------------------
btw: the errata page in the manning site can not display correctly.

After I saw the cawel Errata proposal (50+ errors), I find the errata had listed in it. So sorry for the post.
Message was edited by:
ginkgo
helmers (7) [Avatar] Offline
#18
Re: 2nd Edition Errata
I think they're not updating the errata page because they're ashamed of the enormous amount of errors in the book... an average of at least one error per page...