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

Which one would be invoke first, why?

 
Yorck Zhou
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can anyone please tell me which one would be invoked first in a servlet:
request.getRequestDispatcher("xxx.jsp").include(req, res)
or
pageContext.include("xxx.jsp")
?
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
within a servlet you can't invoke pageContext.include("xxx.jsp") since this object is unknown to servlets. While writing servlets you must invoke Dispatcher.include(ServletRequest,ServletResponse) in a dispatcher aquired with the invocation of ServletContext.getRequestDispatcher or ServletRequest.getRequestDispatcher!
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, its not Dispatcher, it's RequestDispatcher, and you can get a RequestDispatcher by invocating ServletContext.getNamedDispatcher.
 
Yorck Zhou
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, sorry, it should be invoked in a JSP not a servlet.
then can you tell me which one would be invoked first in a JSP:
request.getRequestDispatcher("xxx.jsp").include(req, res)
or
pageContext.include("xxx.jsp")
?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!