What are the differences between the getAttribute()
and the getParameter()
methods in HttpServletRequest
?
getParameter()
returns http request parameters. These are passed from the client to the server. For example http://example.com/servlet?parameter=1
. They can only return String
.
getAttribute()
is for server-side usage only - you fill the request with attributes that you can use within the same request. For example - you set an attribute in a Servlet
and read it from a JSP. These can be used for any object, not just string.