• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding RequestDispatcher.forward

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one doubt:

I know that i can't write response to client before i call forward method of RequestDispatcher, But can i after call that?

My learning says that "I neither write respose before call of forward, nor after call of forward"

Is my understaning right?

Please help in clearing my concepts.

Thanks in Advance.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before the request is dispatched to the client, accidentally output buffer
may written and closed so that output could go to the client.

And when the request is already dispatched, its not meaningful to write
anything to the buffer.

I remind, the output buffer is cleared before the request is dispatched to
the JSP from Servlet.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra thanks for reply!!!

From your answer
----------------------------------------------
Before the request is dispatched to the client, accidentally output buffer
may written and closed so that output could go to the client.
---------------------------------------------

I think you are talking about following two lines:

os.flush(); that will send reponse to client before you call forward.

But if call forward after above statement you'll get IllegalStsteException
right?

Yes, i agree that there is no meaning to write response after calling forward.... but does it give me any exception???
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i agree that there is no meaning to write response after calling forward.... but does it give me any exception???


Did you try it?
If so, what happened?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic