Search code examples
jspservletsforwardrequestdispatcher

is forwarding a dopost or a doget by default?


my simple question is:

by default, when i do request.getRequestDispatcher("\someUri").forward(request, response);

will it be a doPost or a doGet request? and what exacly does it depend on? (assuming i didn't make wrapper class.)


Solution

  • doGet()/doPost() depends on your request 'METHOD' type. If it is GET then doGet(). If it is POST then doPost(). While doing forward you are passing same request as parameter. So, that same request METHOD type decides your forward type.