• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing Request Dispatchers

 
Yogesh Hingmire
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We know that a Request Dispatcher obtained from a ServletRequest can be used to fwd requests to a component relative to the current resource.

Can this RequestDispatcher(obtained from ServletRequest) be used to fwd requests to components in other /contexts. (My understanding is "NO")

Also, would be great if we compare the capabilities of Request Dispatchers obtained from ServletContext and ServletRequest.

Thanks,
Yogesh
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can this RequestDispatcher(obtained from ServletRequest) be used to fwd requests to components in other /contexts. (My understanding is "NO")

It actually can, if your container is configured to. For example, in Tomcat, you can set some Context as being crossContexts, making them accessible to other apps.

Also, would be great if we compare the capabilities of Request Dispatchers obtained from ServletContext and ServletRequest.

The difference between ServletRequest and ServletContext's getRequestDispatcher(java.lang.String) is that ServletRequest's method can take a relative path.
 
Yogesh Hingmire
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou,

So when i use a Request Dispatcher obtained from a Servlet Request to fwd requests to other contexts in the container, i would start with a "/" and this would be an absolute path.Is that correct ?

Yogesh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic