Errata for Advanced Java(TM) Internet Applications Copyright 2002 Art Gittleman p. xv Add just before the Errata heading "Check this site for updates including a revision of Chapter 10 to use version 1.3 of the J2EE reference implementation." p. 24 Line 5 from the bottom Change "SeparaterAdapter" To "SeparateAdapter" p. 59 Line 6 from the bottom Change "PrintWrinter" To "PrintWriter" p. 67 Lines 3, 8, 12, and bottom line p. 68 Line 10 Change ".java/" To ".java" p. 72 Line 12 from the bottom p. 76 Lines 1 and 7 p. 102 Line 9 p. 104 Lines 1 and 4 Change "engr" To "cecs" p. 85 Line 10 from the bottom Change "Figures 7 and 8" To "Figures 2.7 and 2.8" p. 104 Lines 6 and 8 Change "" To "artg@csulb.edu" p. 107 Below Figure 3.3 Change "SalepersonID" To "SalespersonID" p. 120 Figure 3.15 "Name" should be "CustomerName" p. 120 Line 2 from the bottom Change "VARCHAR(4)" To "CHAR(4)" p. 121 Line 10 Change "VARCHAR(2)" To "CHAR(2)" Line 16 Change "VARCHAR(6)" To "CHAR(6)" Line 22 Change "VARCHAR(4)" To "CHAR(4)" Line 22 Change "VARCHAR(2)" To "CHAR(2)" Line 14 from the bottom Change "CHAR(4)" To "VARCHAR(4)" p. 122 Line 7 Add the line "con.close();" after "stmt.close();" p. 136 Add before line 3 from the bottom "NumberFormat cf = NumberFormat.getCurrencyInstance();" p. 136 Change bottom line to + "\t\t" + cf.format(rs.getBigDecimal(4)));" p. 139 Line 21 Change "getInt" To "getString" p. 143 Line 3 from the botom p. 144 Line below Figure 3.18 p. 146 Line 2 Change "Order" To "Orders" p. 146 Line 6 Change "'1999-03-22" To "'1999-03-22'" p. 156 Line 14 from the bottom Change "in" To "it" p. 159 Line 4 from the bottom Change "servlet includes sends" To "servlet sends" p. 162 Line 13 Change "use" To "uses" p. 164 Line 5 Change "need" To "needed" p. 171 Footnote Section 4.3 heading "See http://www.cecs.csulb.edu/~artg/internet/ch4changes.txt for an update to this section." p. 175 Line 8 from the bottom Change "lucky/welcome" To "custom/lucky" p. 191 Footnote to the JSP and JavaBeans Components heading "See http://www.cecs.csulb.edu/~artg/internet/orderbean.txt for another example." p. 194 Line 11 from the bottom Change "request" To "requests" p. 211 Line 8 from the bottom Change "use" To "used" p. 212 Line 2 from the bottom Change "AnimateFlicker" To "AnimateImage" p. 229 Line 14 Change "JPanel" To "JFrame" p. 230 Line 15, Add footnote to Tables heading "See http://www.cecs.csulb.edu/~artg/internet/TableDefault.java for another JTable example" p. 243 Line 3 from the bottom Change "define" To "defined" p. 264 Line 9 p. 266 Line 16 Change "lucinda" To "lucida" p. 264 Line 10 p. 265 Lines 12 and 13 p. 266 Line 16 Change "Lucinda" To "Lucida" p. 271 Line 12 from the bottom Add "import java.awt.event.*;" p. 278 Line 10 from bottom Change 'spaces = " "' To 'spaces = " "' p. 286 Line 7 Change "but it France" To "but in France" p. 288 Line 5 from bottom Change "uses on the year..." To "uses only the year..." p. 301 Line 4 Change "String amount" To "String message" p. 305 Note 4 Change "LabelsList" To "LabelList" p. 307 Line13 from bottom Change "one the styles" To "one of the styles" pp. 329-347 If Examples 8.6-8.13 give a warning message Change "Canvas3D canvas = new Canvas3D(null);" To "GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice d = e.getDefaultScreenDevice(); Canvas3D canvas = new Canvas3D(d.getDefaultConfiguration());" p. 378 Exercise 12 Change "effect" To "affect" p. 382 Example 9.7 Change "smile=(Smiley)Beans.instantiate(null,"smiley.Smiley");" To "ClassLoader cl = this.getClass().getClassLoader(); smile=(Smiley)Beans.instantiate(cl,"smiley.Smiley");" p. 387 There are some changes necessary to some programs in Chapter 10 in order to use J2EE version 1.3 supporting the EJB 2.0 specification. See the link from the home page for this book for details. Corrections below for Chapter 10 refer to version 1.2.1. p. 389 Line 2, Add footnote after "1.2" "See http://www.cecs.csulb.edu/~artg/internet/changes.html for changes needed to use version 1.3" p. 407 Line 20 Change "CustomerHome Component" To "CustomerBean Component" p. 413 Line 18 and line 16 from the bottom Change "CustomerHome" To "AgentHome" p. 413 Line 17 from the bottom Change "Entity" To "Session" p. 413 Line 15 from the bottom Change "CustomerRemote" To "AgentRemote" p. 413 Line 6 from the bottom Change "CustomerHome" To "MyAgent" p. 420 Line 4 Change "of" To "or" p. 427 Line 4 from the bottom Change "return" To "returns" p. 432 Add new line 17 from the bottom "time1 = System.currentTimeMillis();" p. 432 Line 5 from the bottom Change "4747" To "2447" p. 443 Line 1 Change "search" To "searched" p. 449 Line 2 from the bottom Change "different" To "difference" p. 450 Line 5 Change "method" To "methods" p. 454 Line 14 from the bottom Change "to moved" To "to be moved" p. 472 Line 8 Change "ldc_w" To "ldc2_w" p. 476 Figure 12.16 Change "Converstion" To "Conversion" p. 477 Line 9 Change "if" To "of" p. 480 Line 3 Change "form" To "from" p. 485 Line 18 from the bottom Change "Each entry start" To "Each entry starts" p. 498 Line 8 from the bottom Change "name" To "named" p. 499 Line 5 from the bottom Change "Figure 13" To "Figure 13.3" p. 500 Line 8 Change "use" To "used" p. 502 Line 14 from the bottom Change "XML documents" To "XML document" p. 502 Line 2 from the bottom Change "is" To "if" p. 505 When using J2SE version 1.4 or higher no additional download is needed to run Examples 13.1 through 13.6. p. 505 Line 7 Change "classpath." To "classpath, except when using the J2SE version 1.4 or higher which includes the required packages." p. 505 For J2SE v. 1.3, when using the jax_xml_pack-summer-02 or later Change the command to compile Sax.java to "javac -classpath %jaxp_home%\sax.jar Sax.java" Change the command to run Sax to "java -classpath .;%jaxp_home%\sax.jar Sax authorSimple.xml false" p. 506 Line 21 from the bottom Change "import org.xml.sax.XMLReader" To "import org.xml.sax.helpers.ParserAdapter;" p. 506 Omit Lines 17 and 18 from the bottom. "import org.xml.sax.InputSource; import java.io.FileReader;" p. 507 Line 27 Change "XMLReader reader = parser.getXMLReader();" To "ParserAdapter reader = new ParserAdapter(parser.getParser());" p. 507 Line 30 Change "(new InputSource(new FileReader (args[0])));" To "("file:" + args[0]);" p. 509 Change Note 14 to " ParserAdapter reader = new ParserAdapter(parser.getParser()); A ParserAdapter wraps a SAX1 Parser and makes it act as a Sax2 XMLReader." p. 509 Change Note 16 to "reader.parse("file:" + args[0]); The parse method will parse an XML document where the argument is the URL of the document." p. 510 Line 3 Change "Example 1" To "Example 13.1" p. 512 For J2SE v. 1.3, when using the jax_xml_pack-summer-02 or later Change the command to compile Dom.java to "javac -classpath %jaxp_home%\dom.jar Dom.java" Change the command to run Dom to "java -classpath .;%jaxp_home%\dom.jar Dom author.xml false" p. 512 Lines 1 and 9 Change "org.w3c.com" To "org.w3c.dom" p. 516 Add after line 16 import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; p. 517 Replace Line 8, "System.out.println(customer);" with TransformerFactory f = TransformerFactory.newInstance(); Transformer transformer =f.newTransformer(); DOMSource = new DOMSource(document); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); System.out.println(); p. 518 Line 14 Change "a XML" To "an XML" p. 519 Line 2 Change "produces" To "produced" p. 519 Line 3 from the bottom Change "stlyesheet" To "stylesheet" p. 520 For J2SE v. 1.3, when using the jax_xml_pack-summer-02 or later Change the command to compile XmlToHtml to "javac -classpath .;%jaxp_home%\jaxp-api.jar XmlToHtml.java" Change the command to run XmlToHtml to "java -classpath .;%jaxp_home%\jaxp-api.jar XmlToHtml authorSimple.xml authorSimple.xsl authorSimple.html" p. 524 Line 5 from the bottom Change "to the" To "to" p. 529 The ITime server in Example 13.5 is no longer availble. Many other services at www.xmethods.com may be used instead. pp. 531-534 The Barnes and Noble Price Quote service is not available from this site. Here is a replacement using a currency converter service. /* java TrySoapCur services.xmethods.net 80 /soap England Japan */ import java.net.*; import java.io.*; public class TrySoapCur { public static void main(String [] args) { String s; if (args.length != 5){ System.out.println ("Usage: java TrySoapCur host port file country1 country2"); System.exit(1); } try { int port = Integer.parseInt(args[1]); Socket server = new Socket(args[0],port); System.out.println("Connected to host " + server.getInetAddress()); BufferedReader fromServer = new BufferedReader (new InputStreamReader(server.getInputStream())); PrintWriter toServer = new PrintWriter (server.getOutputStream(),true); toServer.println("POST " + args[2] + " HTTP/1.0"); toServer.println("Host: " + args[0]+ ':' + args[1]); toServer.println("Content-Type: text/xml"); toServer.println("SOAPAction: \"\""); String request = "" +"" +" " +" " +args[3]+ "" +" " +args[4]+ "" +" "; toServer.println("Content-Length: " + request.length()); toServer.println(); toServer.println(request); while (!(s=fromServer.readLine()).equals("")) System.out.println(s); while ((s=fromServer.readLine()) != null) System.out.println(s); fromServer.close(); toServer.close(); server.close(); }catch(Exception e) { e.printStackTrace(); } } } p. 532 Line 22 Change ">args[3]<" To ">"+args[3]+"<" p. 533 Line 9 from the bottom Change "%SOAP_HOME%\lib\xerces.jar;%SOAP_HOME%\lib\mail.jar;" To "%JAXP_HOME%\jaxp-api.jar;%JRUN_HOME%\lib\ext\mail.jar;" p. 533 Line 8 from the bottom Change "%SOAP_HOME%\lib\activation.jar" To "%JRUN_HOME%\lib\ext\activation.jar" p. 531 Line 21 p. 533 Line 8 from the bottom Change "1576760235" To "0672319225" p. 535 Line 12 Change "attributes" To "attribute values" p. 535 Line 14 Change "Data Type" To "Document Type" p. 536 Change "reults" To "results." p. 538 Line16 from bottom Change "java.microedition.io" To "javax.microedition.io" p. 542 Line 4 from bottom Change '"Echo,"' To '"Echo ",' p. 542 Line 3 from bottom Change '"Input goes here."' To '"Input goes here".' p. 542 Line 5 from the bottom Change "form" To "from" p. 542 Line 2 from the bottom Change "lower-left" To "lower-right" p. 570 Line 11 from the bottom Change "class class" To "class" p. 572 Line 10 Change "with name" To "with that name" p. 572 Line 4 from the bottom Change "in RecordStore" To "in a RecordStore" p. 598 Bottom line Change "8084" To "8085" p. 599 Line 6 from the bottom Change "FortuneDriver_Stub()" To "Fortune_Driver()" p. 600 Change Note 1 to "We register a remote object that implements the Fortune interface." p. 614 Line 10 from the bottom Change "crate" To "create" p. 618 Figure 16.6 Change "name="<%= request.getParameter("name")%>" />" To "name="<%= request.getParameter(\"name\")%>" />" p. 620 Exercise 5 Change "contain" To "contains" p. 624 Bottom line Change "show the HTML" To "shows the HTML" p. 625 Line 4 from the bottom Change "HelloRepeat.java" To "HelloRepeatTag.java" p. 627 Line 4 Change "int" To "String" p. 627 Line 5 Change "times" To " "" + times" p. 628 Example 16.6 Change "HelloNested.java" To "HelloNestedTag.java" p. 631 Bottom line Change "jarkarta" To "jakarta" p. 634 Line 2 from the bottom Change "16.4" To "16.5" p. 635 Lines 1 and 2 Change "HelloRepeat.jsp to add radio buttons to determine the point size" To "HelloRepeat.html to add a text field to determine the number of times to repeat" p. 635 Line 3 Change "16.4" To "16.5" p. 640 Lines 8 and 10 p. 646 line 12 from the bottom Change "i" To "i%3" p. 640 Line 13 p. 646 Line 9 from the bottom Change "i = (i+1)%3" To "i++" p. 643 Lines 11 and 12 Interchange "Words" and "Numbers" p. 655 Line 3 from the bottom Change "reserved" To "reversed" p. 660 Top Line Change "TryMouseAdapter.java" To "Mouse.java" p. 676 Lines 7, 10, and 12 Change "8000" To "8100" p. 676 Line 19 Change "8080" To "8100" p. 676 Line 6 Change "JRUN_HOME\servlets" To "JRUN_HOME\servers\default\default-app\web-inf\classes" p. 676 Line 9 Change "jsm-default\services\jws\htdocs" To "servers\default\default-app" p. 668 Line 13 Change "href="URL>" To "href="URL">" p. 693 Change "valid documednt" To "valid document" p. 694 Change "Z" To "X"