Servlet Doubt

6

Hello, I have a question with Servlet's.

Imagine the picture:

raiz /
     / formulario.jsp
     / Servlet
     / retornos / retorno.jsp

The form sends the data to the Servlet by post or get!

After this submission, using RequestDispatcher what actually happens?

A) return.jsp is included in form.jsp

B) Servlet redirected the data from it to return.jsp

C) Does Servlet include return.jsp in your body as if you were printing a text?

What happens in reality?

    
asked by anonymous 14.08.2015 / 13:04

1 answer

4

See this link showing example of 2 implementations.

The correct alternative for your question will depend on which RequestDispatcher method you are going to use.

It has two methods: forward (ServletRequest request) and include (ServletRequest request, ServletResponse response)

In the above link, he is implementing a login page as follows:

  • Displays a form with login / password.
  • The user types the user and password and gives submit.
  • If the login / password is incorrect: it gives an include showing the message that the login / password is incorrect. include = on the same screen
  • If the login / password is correct: it gives a forward to another screen saying "Welcome, so and so!" forward = another screen

See also documentation of RequestDispatcher

    
20.08.2015 / 14:52