• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher.forward doubts

 
Victor Dolirio
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

What happen with the line codes placed after a RequestDispatcher.forward, it's perfomed after the forwarded resource finishes its processing or the container creates a new thread for the forward and the perform continues through that service method? What about this code lines if I do a PrintWriter.println, is thrown an IllegalStateException or the passing string parameter also go through the response with the response of the forwarded resource? And what about the additional attributes added by the container? I thought HFSJ weak in those points :S

If somebody know a good material about RequestDispatcher to share with me I would be grateful.
[ October 03, 2008: Message edited by: Victor Dolirio ]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so far what you tried about RequestDispatcher?

why can not you do a small R&D about requestdispatcher?
 
Lakshmi Narayanan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after the forward statement, servlet or jsp is called and the response is sent back to the client by the container. calling servlet or jsp will execute the next statment but the next statement should be "return" for a servlet.
 
Ranil Liyana Arachchige
Ranch Hand
Posts: 71
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First I suggest you to read the Request dispatcher section of servlet version 2.4 specification. That clearly explains about the request dispatcher and its methods too.

servlet-2_4-fr-spec.pdf
Section Chapter SRV 8 , page 63 onwards

If you forward a request to another resource that request is sent back to the client (browser) and then the browser makes a NEW request to the forwarded path. Hence if there is anything written to the response buffer that would get flushed before the actual forward happens. In that case if you write anything in the servlet since the response buffer gets cleared before the forward completes you would not see anything in the output.

Apart from that you can not forward to another resource if you have already committed the response.

Hope this would clear your thought a bit

Regards,
Ranil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic