• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Forward and Include

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic