Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher confusion

 
santoshm
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am having trouble understanding the differences between the getRequestDispatcher methods available in the ServletRequest class
and the Servletcontext class.
Please describe the exact difference as i feel even the API documentation is not clear enough on this.
Thanks in advance.
Santosh
 
no more user
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the API tell that:

The difference between ServletRequest.getRequestDispatcher() and ServletContext.getRequestDispatcher() is that the first can take a relative path.

so, here
request.getRequestDispatcher("./html/file.html");
and here
context.getRequestDispatcher("/html/file.html");
is valid code, but its not:
context.getRequestDispatcher("./html/file.html");
------------------
regards,
alex
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!