When request.getRequestDispatcher is redirected to a doGet or a doPost

0

Dear Luiggi, I have a huge doubt.

I schedule with Servlets and I got the following surprise:

I send data by submit to a servlet_1, then it is captured by a doPost (included!)

from this servlet_1 -> doPost I do a request.getRequestDispatcher (servlet_2) .forward (request, response); Then ... yes I am redirecting with request.getRequestDispatcher ... why it is captured by the doPost (of servlet_2) and not the doGet.

I always assumed that a request.getRequestDispatcher sends data of type GET.

Help me understand this.

    
asked by Max Alí Jara Paredes 20.09.2017 в 18:42
source

2 answers

1

You are calling the doPost because the first request called the method post when the submit was executed, what does request.getRequestDispatcher is to redirect the request not perform another as this was done by POST continue in this way.

If what you want is that when you execute the request.getRequestDispatcher enter the GET method, you must execute it from the first request.

NOTE: Will you only accept Luiggi's answer? If so, I'm sorry.

    
answered by 20.09.2017 в 19:02
0

check the submit, which method addresses, if you enter the post but you want to always enter the get, since in the post you have nothing, then in the dopost, you add the sentence doGet (Request, Response);

    
answered by 21.09.2017 в 00:04