Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why 2 ways to create RequestDispatcher?  RSS feed

 
Abhishek K Gupta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Why do we have two ways of creating a RequestDispatcher ? One through the request object and other through the servletcontext object. One syntax different that I understand is that the first accepts the relative path, while the later accepts absolute path. Aprt from this syntax difference , is there any logical difference between the two ways ?

Thanks,
Abhishek.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The relative path cannot extend outside the current servlet context. To do so, you must use the getContext() method. It returns the absolute URL to the context requested.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!