There are two problems with above code. 1) The request is forwarded after committing the response. This will result into IlligalStateException. In the book it is mentioned. 2) The other is with the line marked Erroneous. Here getResourceAsStream() method accepts string parameter. But the URL path should start with '/' i.e. it will search in and from root.