I'm hoping (figures crossed!) this is correct:
I assume the missing semi-colon in line 2 of the first example is a mistake; I'll assume it should be there, and that there are no compilation errors.
Then since a
JSP expects a JspWriter (subclass of PrintWriter) to fill its 'out' implicit object, the first example should be fine, but the second will throw an
IllegalStateException when the JspPage attemps to invoke response.getWriter() - this is because the getOutputStream() method was already invoked. As many have said, if also the response stream was flushed at any point, that will cause an IllegalStateException with the first method due to the committed response.
I have always found this a particularly difficult issue to resolve (even if it turns out to be an incorrect answer to your question); but then recall that using RD forward should happen as an alternative to writing any content to the response in the calling resource - so in fact, you shouldn't really have obtained any output streams at all in your
servlet! This issue is slightly more difficult to justify with includes, but then why would you want to include binary and text data in the same response anyway? So yes, a slightly unsettling issue, but nothing that can't be resolved...
Oh, and by the way, another possible outcome is that a NullPointerException is raised in both if the "result.jsp" resource doesn't exist (since then view is null).
Phew... I think that stuff was just about on the tip of my tongue after spending days and days writing exam-style questions!