Errata 1st printing

It is our goal at Manning Publications to provide error-free texts. Inevitably, however, minor errors creep into every book in production. If you discover any mistakes in the book, you may post them in the Author Online Forum.

These errors were found in the book's First Printing.

Errata for the book's Second Printing (September 2002).


Page 9:

The directory name should read as jakarta-tomcat-4.0.1. (Notice the - between tomcat and 4.)


Page 9, Section 1.3.3:

Insert the following lines at the start of code snippet in 2nd point:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


Page 16, Section 2.2.2:

Replace URL to the servlet should be:

http://localhost:8080/chapter01/servlet/HelloServlet?userName=John

(Remove "s" from servlets)


Page 35, Section 4.2, 1st line:

Current:

public void doXXX(HttpServletRequest, HttpServletResponse)
throws ServletException, IOException;

Change To:

protected void doXXX(HttpServletRequest, HttpServletResponse)
throws ServletException, IOException;


Page 38, Table 4.4,
Page 64 and 418, Question 7, option b, and
Page 524-525 (index entries):

Replace getHeaderValues with getHeaders.


Page 38, Table 4.4, 4th line of second column:

Current: "....as an enumeration of String object."

Change To: "....as an enumeration of String objects."

(append s to object)


Page 41, Table 4.5:

The third line should be:

This method should be called before getting the PrintWriter from the ServletResponse.

and:

Using ServletOutputStream, 2 lines above Table 4.5:

Current:

"....call this method before calling getPrintWriter()."

Change To:

".....call this method before calling getWriter()."


Page 43, Redirecting the request, Code at the end of the page:

Current:

PrintWriter pw = res.getPrintWriter();

Change To:

PrintWriter pw = res.getWriter();


Page 48, Table 4.8:

Add the word 'void' at the start of the second point:

void service(ServletRequest, ServletResponse);


Page 50, Listing 4.6:

Move the load-on-startup tag after the last init-param tag.


Page 52, Listing 4.8:

Current:

URL url = context.getResource("files/test.jar");

Change To:

URL url = context.getResource("/files/test.jar");


Page 53, Middle of Listing 4.8:

Change: URL url = context.getResource("files/test.jar");

To: URL url = context.getResource("/files/test.jar");

(Insert a / just before files).


Page 57, Top (first) Note:

Replace all three occurances of HttpRequest.sendRedirect() to HttpServletResponse.sendRedirect() and one occurance of HttpRequest.forward() to RequestDispatcher.forward().


Page 58, Listing 4.9:

Change method signature of the doGet() and doPost() method

Current:

public void doGet(HttpServletRequest req,
                  HttpServletResponse res)
public void doPost(HttpServletRequest req,
                   HttpServletResponse res)

Change To:

public void doGet(HttpServletRequest req,
                  HttpServletResponse res)
                  throws ServletException, IOException
public void doPost(HttpServletRequest req,
                   HttpServletResponse res)
                   throws ServletException, IOException


Page 60, Listing 4.11:

The words "user ID" should be one word as "userid."


Pg 62, 4.10 Review Question # 3:

PrintWriter out = res.getWriter);

Notice the missing '(' in getWriter();

and in the last line, there is a missing '(' in res.getWriter();


Page 64 and 418, Question 7:

Remove option (b) and renumber the options


Page 69, Section 5.1.3:

Bullet 1 and 2 and the line following the bullets should be as follows:

    1. From the DOS prompt (or $ prompt), go to the webapps\helloapp directory
      ( c:\jakarta-tomcat4.0.1\webapps\helloapp)
    2. Jar the helloapp directory using the jar utility:
      c:\jakarta-tomcat4.0.1\webapps\helloapp>jar -cvf helloapp.war *

This will create a helloapp.war file in the webapps\helloapp directory.


Page 71, Listing 5.1 and first line after the listing:

Current:

<?xml version="1.0" encoding="ISO-8859-1">

Change To:

<?xml version="1.0" encoding="ISO-8859-1" ?>

(Insert ? before the closing > )


Page 74, 3rd bullet:

Current:

<url-pattern>report</url-pattern>

Change To:

<url-pattern>/report</url-pattern>


Page 76, Point # 3:

Current:

"…the complete request URI is the servlet path…"

Change To:

"…the complete request URI, minus the context path, is the servlet path…"


Page 85:

Missing full stop in the last line of second paragraph immediately before ServletContextEvent extends java.util.EventObject.


Page 92 and 426:

Ending <contex-param> should be </context-param>


Page 97, Listing 7.2:

Current:

private double debit(String accountid, double amount)
throws InsufficientFundsException

Change To:

private double debit(String accountId, double amount)
throws InsufficientFundsException

(Change the accountid to accountId)


Page 103, Last line of NOTE should read:

... java.servlet.error.status_code is set to null.


Page 104:

Replace "Serlvet" with "Servlet" in Step 2 of A.


Page 105, Section 7.3, 1st Code example:

Current:

String accountId = req.getSession().getAttribute("accountId");

Change To:

String accountId = (String) req.getSession().getAttribute("accountId");

and, 1st Code example in the catch clause

Current:

req.setAttribute("javax.servlet.error.servlet_name",
req.getServletName());

Change To:

req.setAttribute("javax.servlet.error.servlet_name",
getServletName());


Page 109 and 428, Question 2:

Remove the line:

out.flush()


Page 121, Listing 8.4:

Current:

public void sessionDestoyed(HttpSessionEvent e)

Change To:

public void sessionDestroyed(HttpSessionEvent e)

(insert the missing "r" in sessionDestroyed)


Page 128:

Change All the "JSESSIONID" to "jsessionid"


Page 130, Question 2, Option d:

Current:

session.setAttribute("count" , new Integer(count++));

Change To:

session.setAttribute("count" , new Integer(++count));


Page 144, Section 9.3.3:

Error in example. Current:

<security-role>
    <role-name>manager</role-name>
    <role-name>director</role-name>
    <role-name>employee</role-name>
</security-role>

Change To:

<security-role>
    <role-name>manager</role-name>
</security-role>
<security-role>
    <role-name>director</role-name>
</security-role>
<security-role>
    <role-name>employee</role-name>
</security-role>


Page 148, Running the example, (4th line from the bottom):

Current:

"since bob is the only user we have defined in the deployment descriptor with the role of supervisor"

Change to:

"since bob is the only user we have defined in the tomcat-users.xml with the role of supervisor"


Page 149, Table 9.1, 1st column:

Current: String getRemoteUser

Change to: String getRemoteUser()


Page 151:

In summary, chage CLIENT to CLIENT-CERT


Page 155 and 440, Question 11, Option c:

Change: HttpServletRquest.getUserInRole()

To: HttpServletRquest.getUserInRole(rolename)


Page 160, Figure 10.3:

Figure 10.3 is a duplicate of Figure 10.2. Here is the right figure:


Page 171:

Remove the word 'private' from local variables HttpSession and ServletContext.

and in Question 3, 5th and 6th line:

Current:

private static Hashtable statichash = new StringBuffer();
private Hashtable instancehash = new StringBuffer();

Change To:

private static Hashtable statichash = new Hashtable();
private Hashtable instancehash = new Hashtable();


Page 181, Table 11.2:


10th entry should read:

A method returning a float


Page 188:

In the throws clause of the code sample at the top of the page

Current:

javax.IO.IOException

Change to:

java.IO.IOException


Page 190, Third paragraph:

The text in bold is missing. The pragraph should read as follows:

Because the JSP page is converted into a servlet, we can call all the methods in a JSP page that we can call on a servlet. Hence we can get the ServletContext object via getServletConfig().getServletContext(). However, in tomcat and in many other containers, the base class of the page's generated class also implements the ServletConfig interface. Thus, in both methods, jspInit() and jspDestroy(), we get the ServletContext object by using the method getServletContext(), which is actually defined in the javax.servlet.ServletConfig interface.


Page 196, Section 11.3.7:

Remove extra to: Info attribute allows *to* us to ...


Page 210: Second line under A:

Change int i=0; to int i;


Page 218:

Second line in Quizlet code should read:

public void jspInit(){


Page 226:

Answer to the first Quizlet provides explaination for two errors in the quizlet question. But there are three errors. The third is that the root element should read as:

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2" >.

The quotation marks in the quizlet question are in the wrong place.


Page 229 and 450, Question 11, Code 2nd line:

Current:

<%int i = 10 ;%>

Change To:

<%int i = 10;%>

(Remove the space between 10 and ;)


Page 235, Top of the page:

Current:

<String pageURL = "other.jsp" %>
<jsp:include page="<%=pageURL%>" />

Change To:

<String pageURL = "other.jsp"; %>
<jsp:include page="%=pageURL%" />


Page 239, 4th line from the end of 13.2.3:

Current:

("first") after paramTest2.jsp...

Change to:

("firstname") after paramTest2.jsp...


Page 242, Second Q, third line:

Current:

xmlns:jsp=http://java.sun.com/JSP/Page

Change to:

xmlns:jsp="http://java.sun.com/JSP/Page"


Page and page 244 and 452:

Option 2 should end with %> instead of />


Page 257:

Last sentence should start as:

"Otherwise, a new object of class AddressBean is created, ..."


Page 259, Using Serialized beans:

Change the 2 occurrences of businessData.Address.John to businessData.visitorAddresses.John


Page 263:

Scope of the declared variable, Code at the start of the page, 5th line from end of the code:

Current:

Out.print("Zip: " + address.getZip(); //error here

Change To:

Out.print("Zip: " + address.getZip()); //error here

(Missing bracket)

and the Code snippet at the center of the page 7th line:

Current:

out.print("Zip: " + address.getZip(); //ok

Change To:

out.print("Zip: " + address1.getZip()); //ok

(Add a closing bracket at the end)


Page 274, 6th line from the top:

Change <jsp:getProperty> to <jsp:setProperty>

and in the 4th paragraph:

Change <setProperty> to <jsp:setProperty>.


Page 279:

Question #8 should read (select two) instead of (select one)


Page 286, section 15.2.1, 2nd paragraph, 5th line:

web-inf should be caps as WEB-INF


Page 293, Section 15.3.2:

First code snippet line 2

Current:

attrib2="<%=someJSPExpresson%>"

Change To:

attrib2="<%=someJSPExpression%>"


Page 300, Listing 16.1 and Page 301, Second Line:

Current:

<?xml version="1.0" encoding="ISO-8859-1">

Change To:

<?xml version="1.0" encoding="ISO-8859-1" ?>

(Insert ? before the closing > )



Page 303, Section 16.1.1:

Current:

<%@ taglib prefix="test" uri=" http://www.manning.com/sampleLib" %>

Change To:

<%@ taglib prefix="test" uri="http://www.manning.com/sampleLib" %>

(Remove the space in the uri after the =")


Page 305, Section 16.1.3, 5th line from the end of the page:

Current:

"...a value of false for the <rtexprevalue> element...."

Change To:

"...a value of false for the <rtexprvalue> element...."


Page 323, Table 16.8:

Heading should be:

Methods of the javax.servlet.jsp.tagext.BodyTag


Page 323, Last Line:

Current: public void doInitBody(BodyContent) throws JspException;

Change to: public void doInitBody() throws JspException;


Page 326, Listing 16.4, Last line on the page:

Current:

if (newIndex<=oldIndex) {

Change To:

if (newIndex<oldIndex) {


Page 328 and 329, Table 16.9 and 16.10:

The return type for the first three methods is int.


Page 334:

The title for Listing 16.8 should be 'CaseTag.java' not 'Case.java'.

and,

Last line should use parent.getValue() as

Object conditionValue = parent.getValue( "conditionValue" );


Page 336, First line after the code ends:

Current:

"The implentation of the …"

Change To:

"The implementation of the …"


Page 338, First sentence of Summary:

Change tab to tag.

"In this chapter, ...custom tag library."


Page 339 and 466, Question 3, 5th line of code:

Current:

<% message = message + "World! " %>

Change To:

<% message = message + "World! "; %>


Page 358, Fifth bullet on the page:

Current:

Increase response time

Change To:

Improve response time


Page 393, Listing 18.5:

Current:

HttpServletRequest req = (HttpServletRequest) response;

Change To:

HttpServletRequest req = (HttpServletRequest) request;


Page 417, 5th line from the top:

Current:

The ServletRequest.isCommitted()...

Change to:

The ServletResponse.isCommitted()...


Page 430, explanation of question 7, third line of code:

Current:

<location>customernotfoundpage.html</location>

Change to:

<location>/customernotfoundpage.html</location>


Page 452: Question 2: Option b

Current:

<%@ include file="test2.jsp" />

Change To:

<%@ include file="test2.jsp" %>


Page 459:

Question #8 should read (select two) instead of (select one). Answer at the bottom of the page should be a and d


Page 460, Explanation at the top of the page:

The underlined part is to be deleted and bold part in the following is to be inserted.

...therefore, we cannot use answers a, b and c. However, the object is still existent and is avaliable in the session scope. This means we can either use the <jsp:getProperty> action to print the street property or use the implicit variable session to ...
Therefore, answers a and d is are correct.