Something in general got lost, guys. Help, please. I can not understand the following things on MVC on JAVA:

1. Everyone says that the request is forwarded, but the method Request class RequestDispatcher forwards both the request and the response.

2. Why exactly in request we add attributes? And why not in response?

3. Why do not add attributes in response?

4.Why do we get attributes in jsp?

Why, then, in general, such an attribute is a server variable that exists at the time of the request. (I’m talking about the context of the request). But this is not enough for me.

I can’t hear anything about response at all. When I sent requests, I had never met a response object in MVC. Just get the attributes from the received request and display them.

  • For example, there is html (the form is Surname), jsp and there is a servlet.html the form makes a request for a servlet. jsp is unreal. But the request attributes can contain the name of the attribute and the object itself, which is wildly convenient for displaying on jsp. In general, you should try to separate the logic from the view and I am for it. - Sckoriy

1 answer 1

1) forward forwards the request from one resource to another along with the response of the first

2) We add that the resource that processes the request has parameters that can be displayed, processed, etc. The requested resource can put in response stream

3) Used the stream

4) To display, calculate, etc.