request.setAttribute() sets the value in the current request. When you use RequestDispatcher and forward(), the same request is forwarded to the
jsp and you get access to the value set in the attribute.
Now when you click the link, the request gets redirected to the page. So it is another request at this time and the original request and any values associated with it are gone at this point. Clickiing the link never goes to the Servlet again, it is directly redirected to the page by the web server.
Hope this helps!
Sincerly,
Your friends at
www.javaadvice.com www.javaadvice.com - The one stop resource for all your
Java questions and answers.