Difference between request.getParameter() and request.getAttribute()

The difference between getAttribute() and getParameter() is that getParameter() will return the value of a parameter that was submitted by an HTML form or that was included in a query string.

getAttribute() returns an object that you have set in the request, the only way you can use this is in conjunction with a RequestDispatcher. You use a RequestDispatcher to forward a request to another resource (JSP / Servlet). So before you forward the request you can set an attribute which will be available to the next resource.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.