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

Request Dispatcher query  RSS feed

 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RequestDispatcher is present in two places ,
1) javax.servlet.http.HttpServletRequest
2) javax.servlet.ServletContext

in (1) it says that it will accept Relative path and should start with "/"

in (2) it says that it will should start with "/"

I think that both take relative path because if we use "/" , then it is relative path , so what does it actually mean.

Thanks
Regards
Gaurav
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ram,

Read the API again.


The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. This method returns null if the servlet container cannot return a RequestDispatcher.


If obtain the reference to the dispatcher via request.getRequestDispatcher, it can either be relative to the request (no slash at the beginning) or relative to the context itself (with precedeing slash).

If you obtain the reference via the ServletContext object, you have to use the preceding slash.
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot , now i understand the basic difference
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!