Difference between getAttribute () and getParameter: attribute and parameter
When the forwarding relationship is between the two Web components, the conversion source will share the data within the request range and put the data into the HttpServletRequest object with setAttribute, and then forward the data to the target throughGetParameterAndGetParameter() Method to obtain Request Parameters. For example, if the link between welcome. jsp and authenticate. jsp is a link, the following code is available in welcome. jsp:
Authenticate. jsp
Or:
Enter the User Name:
In authenticate. jsp, request.GetParameter("Username"); %>
(3)The getAttribute () method shares the request and session data with the conversion source component.
Assume that the relationship between authenticate. jsp and hello. jsp is forwarding. Authenticate. jsp wants to pass the current username to hello. jsp. How can this data be transmitted? First, call the setAttribute () method in authenticate. jsp:
<%
String username = request.%>
In hello. jspGetAttribute("Username"); %>
Hello: <% = username %>
From a deeper perspective, request.GetParameter() Method returns data of the String type.
Request. setAttribute () andGetParameter() Data is obtained through the implementation of the container and transmitted through methods such as post and get.
Request. setAttribute () andGetAttributeIs the returned object,GetAttribute() Method returns the objects in the reques, sessiont range, and request.GetParameter() Method is to obtain the data submitted by http.