• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why it is not correct?

 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic