JSPs and Servlets Tutorial 16 Part 4- Using RequestDispatcher in the MVC Application

preview_player
Показать описание
The RequestDispatcher object helps us transfer the request from the controller to the view.
Рекомендации по теме
Комментарии
Автор

Leave it to an Indian to give a nice, clear, easy to understand explanation.
I swear, I've learnt more about programming from Indians on YouTube, than I've ever done in Uni!
Thank you!

mattanderson
Автор

this course was, really thank youu, java brains is the best in java tutorials

sajadsh
Автор

Thank you, very much for all this helpfull tutorials, you've help me so much to have a much more clear knowledge and understanding of JSP & Servlets.
 

DanLMx
Автор

requestDispatcher - forward() method
When we use forward method, request is transfer to other resource within the same server for further processing.
In case of forward, web container handle all process internally and client or browser is not involved.
When forward is called on requestdispatcher object we pass request and response objects so our old request object is present on new resource which is going to process our request.
Visually we are not able to see the forwarded address, it is transparent.
Using forward () method is faster then send redirect.
When we redirect using forward and we want to use same data in new resource we can use request.setAttribute () as we have request object available.
SendRedirect
In case of sendRedirect, request is transfer to another resource to different domain or different server for further processing.
When you use sendRedirect, container transfers the request to client or browser so URL given inside the sendRedirect method is visible as a new request to the client.
In case of sendRedirect call, old request and response objects are lost because it’s treated as new request by the browser.
In address bar, we are able to see the new redirected address. It’s not transparent.
sendRedirect is slower because one extra round trip is required, because completely new request is created and old request object is lost. Two browser request required.
But in sendRedirect, if we want to use we have to store the data in session or pass along with the URL.


chanzhao
Автор

Awesome! Just absolutely freaking awesome job! God bless your efforts!

sparkman
Автор

Great series. Can you go into more detail that what is the best scenario for each method?

chongliwan
Автор

wonderful video ! simple and awesomely clear !!

sathyavani
Автор

Very nice explanation and simple to understand . Keep posting such videos :)

kyasamadhavi
Автор

this is so cool, the real deal :)
it would be even more awesome if You did this with a real database

SoeaOu
Автор

7:35 User user = (User) session.getAttribute("user");
error : The method getAttribute(String) in the type HttpSession is not applicable for the arguments (User)

rahulsolanki__
Автор

I'm not sure why the HashMap was not changed to contain userId against User objects. It seems like there is a bad separation of function is some of this code, though I expect it's only because it's rushed through to show us as an example. If someone thinks otherwise, I would be pleased to hear it. (Also, great serious, thanks for your dedication JavaBrains!)

zenmasterfu
Автор

Why can't you just add another attribute to the request scope to contain the User Object instead of using the session?
*EDIT: nevermind, question answered in 7:08

misterlemzki
Автор

Very well explained!!! v.v.v.v.v good!!

zerziszain
Автор

i am surprised why this video does not show up when i search for "RequestDispatcher" in youtube searchbox.

sudipto.m
Автор

Why we cannot use the application scope? If there are more than 1 user for the application each user will have a different thread. Then how it does not make sense to use the application scope? I am not clear.

suhaasmohandos
Автор

Am I the only one going through this tutorial in 2023

vickyyy_
Автор

Why i am having this error: ttpstatus 500 - java.lang.classDefFoundError?
I did everything like in the tutorial.

acegulabot
Автор

The session object is itself obtained from the request object by calling request.getSession(). Then how come session is having more scope compared to request? If I have two requests request1(on submission of the form) and request2(on calling sendRedirect) and obtain the session objects as request1.getSession() and request2.getSession how can we expect both sessions to be equal? This is so confusing

suhaasmohandos
Автор

Hi, where can we find these programs?IS it available on your site ?

saurabhchaudhari
Автор

it does not work for me :(. keep saying "hello null" in the success.jsp screen.

khoanguyen-rusp