What is the difference between getAttribute()
and getParameter()
methods within HttpServletRequest
class?
getParameter
- Is used for getting the information you need from the Client's HTML page
getAttribute
- This is used for getting the parameters set previously in another or the same JSP or Servlet page.
Basically, if you are forwarding or just going from one jsp/servlet to another one, there is no way to have the information you want unless you choose to put them in an Object and use the set-attribute to store in a Session variable.
Using getAttribute, you can retrieve the Session variable.