File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes why it is not correct? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "why it is not correct?" Watch "why it is not correct?" New topic
Author

why it is not correct?

Yuan Ye
Ranch Hand

Joined: Mar 05, 2003
Posts: 172
The following option is from a question in javaprepare.com:
The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server.
Is it ture of false? The forward() method must be called before the respose is committed. Is it also ture for include() method?
Thanks
eric mcentee
Ranch Hand

Joined: May 02, 2001
Posts: 66
The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server.
Is it ture of false? The forward() method must be called before the respose is committed. Is it also ture for include() method?

1) The forward method must be called before the response is committed since it forwards the current request to the next resource for processing. If the response has already been commited the request is no longer valid and an Illegal State Exception is thrown.
2) The include method can be called whenever since the request is not forwarded permanently. It is passed to the next resource temporarily for processing purposes, but any changes to the headers or status codes of the request by the called resource are ignored.
This is from page 56 Table 4.12 of Deshmukh / Malavia
- Eric
Yuan Ye
Ranch Hand

Joined: Mar 05, 2003
Posts: 172
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why it is not correct?