This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher forward

 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am calling the forward() method of the RequestDispatcher. After the call, in the calling servlet, is the response.isCommited method alway return true. That is, I want to know Does the response alway commited after call to forward method? Nothing is given in the Specifiactions.

Thanks
 
Rodrigo Dinis
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you didnt call the flush method in the caller servlet/jsp the output stream inst closed and you can use the output stream in the calling servlet without matters. If you flush so a fat IllegalStateException will be throwed.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not talking about closing of the out stream. After the forward method return to the calling Servlet, Can I use the out stream in any condition ?. In my testing the isCommited() method retrun alway true.


Thanks
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Narendra Dhande:
After the forward method return to the calling Servlet, Can I use the out stream in any condition ?. In my testing the isCommited() method retrun alway true.


I always thought we were not supposed to have any code after a forward statement (apart from a return stmt).
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even after calling forward, we can have logic that does not write to the stream. Its not good programming but its valid.

Intuitively it makes sense that isCommited should return true after forwarding the request. if isCommited returns false then it would mean that we could write to the stream which is not correct.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know that the out.iscommited() method always return true or some case it can return false (i.e I can write to stream). For the sendError, sendRedirect methods of the HttpServletResponse it is clearly stated in Specs that After using these methods, the response should be considered to be committed and should not be written to. But for the forward() method for RequestDispatcher is is not specified anywhere. Though it is not good parctice to write after the forward method, I want to confirm it in view of Exam (There is seperate piont on RequestDispatcher)

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic