Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher  RSS feed

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

we can get request dispatcher either from the ServletContext or the Request ....

Whats the difference..and what should be the best choice for a programmer..


Regards
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the javadoc for HttpServletRequest explains the difference.

which you use is up to you, your application's needs and your design philosophy (which should reflect those needs of course).
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked up ...

and the difference is that...

RequestDispatcher from request...can take relative path

unlike that from the servletcontext..

but is there performance issues when we decide for the usage among these two..

Regards
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there isn't.

The request object can deliver a request dispatcher with a relative address because it knows the address from which you've requested it.

The servlet context on the other hand, doesn't know what the requestURI is.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!