This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have login servlet which on validation generate html page(from servlet) with all related user data.
That has two links .
I want that user will go to another servlet or html page with request and response by clicking on link.
Now the problem is if i use <a href> request and responce would not forwarded.
If RequestDispatcher will used how to manage which link is clicked.
Once the current request and response has been sent to the browser, it's done. What you are asking for is impossible. After the user clicks a link, a new request is generated and there can be no access to the previous request or response.
Why do you feel that you need this access? It's just not how HTTP works, so whatever you are trying to accomplish will need to be satisfied by other means.
The basics: get the session from the request instance, set an "attribute" (more properly called a scoped variable) on the session. You can retrieve this value from any request participating in the same session.