The HttpServletRequest class has GetParameter (), getattribute (), setattribute (), and no Setparameter () method
GetParameter () is used to post or get the form, to obtain the data in the form, or the parameters on the URL.
When the Web component is linked (I think this refers to web redirection), the linked Web component obtains the parameter by GetParameter () method
We have included the following code in the b.jsp:
<!--b.jsp-->
<a href= "A.jsp?username=admin" >a.jsp</a>
or form Post/get Submission method
<!--b.jsp-->
<form ame= "form" method= "POST" action= "a.jsp" > Username: <input type= "text" Name= " Username "/> <input type=" Submission "name=" submit "value=" submitted "/></form>
The username parameter in the b.jsp is submitted to the a.jsp, so we can get getparameter by username in the a.jsp
<% String username=getparameter ("username");%>
The data passed by the Request.getparameter () method is uploaded from the Web client to the Web server side, representing the HTTP request data. The Request.getparameter () method returns the data of type string.
When a forwarding relationship is between two Web components, the forwarding target component shares the data in the request scope through the GetAttribute () method and forwarding the source component. Assume a forwarding relationship between a.jsp and b.jsp
A.jsp wants to pass the current user name to b.jsp and how to pass the data. First call the SetAttribute () method in a.jsp:
<%
String username=request.getparameter ("username");
Request.setattribute ("username", username);
%>
<!--forwarded to b.jsp-->
<jsp:forward page= "b.jsp"/>
The user name is obtained by the GetAttribute () method in b.jsp
<% string Username= (String) Request.getattribute ("username"); %>
Username: <%= username%>
The data passed by the Request.setattribute () and GetAttribute () methods only exist within the Web container and are shared among Web components that have forwarding relationships. These two methods can set the shared data of type object.
Summarized:
Request.getparameter () acquisition is achieved through the implementation of the container to obtain through similar post,get and other means of data passed in.
Request.setattribute () and getattribute () only flow within the Web container, only the request processing phase.
GetAttribute is the return object, GetParameter returns a string
Overall:
Request.getattribute () method returns an object that exists within the Reques,sessiont range
The Request.getparameter () method is to obtain data submitted by HTTP.