I've read two conflicting descriptions of what happens if you call response.setHeader() after dispatch.forward(). One says you will get an IllegalStateException, the other that it simply has no effect (but no exception is thrown).
My own tests on Tomcat seem to indicate it has no effect (with no exception thrown). Can anyone confirm that? Is it in the spec? Or up to the vendor?
I strongly believe it has no effect. If the exception were defined in the specs, the API docs tend to explicitly state "If the response has already been committed, this method throws an IllegalStateException", and they don't say that for any of the header methods. I remember a brain-slip in my book on p.132 which has been mentioned in the errata (here if you haven't seen it already). The statement on p.105 about no exception being thrown is correct.
I doubt such a question would come up on the exam however. Hope that helps. [ December 06, 2008: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!