Win a copy of The Java Performance Companion this week in the Performance 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")
?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic