When a forwarding relationship is made between two Web components, the forwarding source will share the data in the request scope first with setattribute to put the data into the HttpServletRequest object, and then forward the target through getparameter and GetParameter () method to obtain the request parameters, such as assuming a link relationship between welcome.jsp and authenticate.jsp, with the following code in WELCOME.JSP:
authenticate.jsp
Or:
Please enter user name:
Through the request in authenticate.jsp. GetParameter ("username"); %>
(3)getattribute () method to share data in the Request,session range with the forwarding source component.
Assume that there is a forwarding relationship between authenticate.jsp and hello.jsp. Authenticate.jsp want to pass the current user name to hello.jsp, how to pass this data? First call the SetAttribute () method in authenticate.jsp:
<%
String Username=request. %>
In hello.jsp through getattribute("username"); %>
Hello: <%=username%>
From a deeper level of consideration, request. GetParameter The () method returns data of type String.
Request.setattribute () and getparameter() are obtained through the implementation of the container to obtain data that is passed in such a way as post,get.
Request.setattribute () and getattribute are return objects, and thegetattribute() method returns objects that exist in the Reques,sessiont scope, and request. GetParameter () method is to get the data submitted by HTTP.
The difference between getattribute () and GetParameter