What is the difference between getAttribute()
and getParameter()
methods within HttpServletRequest
class?
Generally, a parameter is a string value that is most commonly known for being sent from the client to the server (e.g. a form post) and retrieved from the servlet request. The frustrating exception to this is ServletContext initial parameters which are string parameters that are configured in web.xml and exist on the server.
An attribute is a server variable that exists within a specified scope i.e.:
application
, available for the life of the entire applicationsession
, available for the life of the sessionrequest
, only available for the life of the requestpage
(JSP only), available for the current JSP page only