I developing this web app using jsp and servlets. I was wondering how to display results on same page as on from which the request was made. For example, usually what I do is that a request is sent from one jsp to a servlet and then servlet sends the response/results on separate jsp. I am want to show a database results on same page. How can this be done?..A code snippet would be appreciated. Thanks
Share
Just set the necessary data in the request scope and use
RequestDispatcher#forward()to forward the control to the desired JSP which in turn can generate the appropriate HTML based on the results.This is also demonstrated in the hello world examples in our servlets wiki page.