Corrections to Chapter 8 of Java Network Programming, HTML in Swing

p. 268: In the second paragraph change "can set include" to "can include".

p. 271: In Example 8-11, the matches() method should also check the domain. That is, it should read:

  public boolean matches(URI u) {
    
    if (isExpired()) return false;
    
    String path = u.getPath();
    if (path == null) path = "/";
    
    String domain = u.getHost();

    if (path.startsWith(this.path) 
      && domain.equals(thisdomain)) {
        return true;
    }

    return false;
  }

In fact, this isn't quite good enough because we also need to handle the case where a cookie for the domain example.com should apply to a request from foo.example.com and bar.example.com. I'll leave that as an exercise for the reader.

[ Java Network Programming Corrections | Java Network Programming Home Page | Table of Contents | Examples | Order from Amazon ] ]

Copyright 2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified October 10, 2007