getParameter() | getAttribute() |
---|---|
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 |
the return type for a parameter is a String | The return type for attributes is an Object |
The Scope of parameter is per individual request | attribute is a server variable that exists within a specified scope application, available for the life of the entire application session, available for the life of the session request, only available for the life of the request page (JSP only), available for the current JSP page only |
request.getParameter(“parameterName”) in java is used for accessing variable from JSP or HTML | RequestDispatcher.forward(request, response) in java and request.getAttribute(“attributeName”) in jsp are used for accessing variables |