jsp - Using RequestDispatcher to forward to the same page that send request -


i have servlet, called "loginservlet", index.jsp, has login form (username & password). send request loginservlet, , used:

getservletcontext().getrequestdispatcher("/index.jsp").forward(request, response); 

to go index.jsp username , user information (to display welcome xxx on top right of screen). problem is, cannot use ${requestscope.username} retrieve username. username not exist in request. however, when dispatched jsp page, did receive request new information , retrieve it.

i want know there way forward same page send request? cannot data dispatched servlet same page, i.e. making user logged in


Comments