• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forward and Include

 
Akhil Maharaj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Here is my interpretatin of Servlet2.4 spec (Page 65 and 66 )

Let us say Request goes to MyServlet and it includes ServletA .
Now inside ServletA's code , javax.servlet.include.request_uri attribute will give the requestURI of ServletA.

On the other hand
Let us say Request goes to MyServlet and it gets forwarded to ServletA .
Now inside ServletA's code , javax.servlet.forward.request_uri attribute will give the requestURI of MyServlet. Even if original request gets forwarded from ServletA to ServletB to ServletC , the attribute javax.servlet.forward.request_uri will always correspond to original request from client.

Can some body clarify why it is different ?

Thanks
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Well is a question of where the entire stuff is hapent.
When you forward, the response and the request goes on the other servlet and the servlet where you forward will do the final response. So the the servlet where you forward will get the control (permanent) over the resource.

When you include the response and the request goes on the other servlet and
the the servlet which make the include call is responsible for the final response, and the control over the resources is only temp passed to the other servlet.

Regards
M
[ March 06, 2008: Message edited by: Mihai Radulescu ]
 
Akhil Maharaj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic