Several Methods for passing JSP page values:
1. Hide the field transfer value:
<Form method = "Post" Action = "client_crud.jsp">
<Input type = "hidden" name = "ID" value = "<% = ID %>">
2. url transfer value:
Use button
A.
<Input name = "btnmodify" type = "button" class = "button1" onclick = "self. Location = 'client _ modify. jsp? Id = <% = ID %> '"
Value = "Modify distributor"/>
B. Set the onclick = "modifyregion ()" of input ()"
Function modifyregion (){
Window. Self. Location = client_node_modify.jsp? Id = <% = ID %> ";
}
3. Pass values in JS Mode
// Obtain the form object submission form
With (document. getelementbyid ("userform ")){
Method = "Post ";
Action = "user_add.jsp? Command = Add ";
Submit ();
}
Function searchitem (){
With (document. Forms [0]) {
Action = "Servlet/basedata/searchitemservlet ";
Method = "Post ";
Submit ();
}
}
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------
Parameters of JSP:
I. Hyperlinks
<A href = "P. jsp? Username = zhangshan & Pwd = 123456 & age = 25 "> link </a>
Ii. Forma form
1. display controls
<Input type = "text" name = "username">
2. If the value to be passed is not displayed on the page
(1) <input type = "hidden" name = "PWD" value = "<% = PWD %>">
(2) <form action = "XXX. jsp" method = "Post"> </form>
Iii. jsp include and forward labels
<JSP: Include flush = "true" page = "T. jsp? Username = zhangshan & Pwd = 123456678 ">
<JSP: Param name = "Age" value = "28"/>
</Jsp: Include>
Iv. Javascript
Script Type = "text/JavaScript">
Function demo (){
VaR v = Document. All ('username'). value;
Location. Replace ("V. jsp? Username = "+ V +" & age = 25 ");
}
</SCRIPT>
<Input type = "text" name = "username"> <br>
<Input type = "button" value = "href click" onclick = "location. href = 'v. jsp? Pwd = 123456 '"> <br>
<Input type = "button" value = "replace click"
Onclick = "location. replac ('v. jsp? Pwd = 123456789 ') ">
<Br>
<Input type = "button" value = "dynamic value" onclick = "demo ()">
Note: Data submission methods include get and post.
1. Difference Between get and post
A. GET requests can only process small data <2 K
Post can be used to submit Big Data
B. The post submission method is relatively secure.
Get is only suitable for transferring small data. That is to say, only post can transmit big data. For example, when uploading a file
Post
2. Post submission:
When the method attribute of your form is specified as post, the submission method is post.
All other cases are GET requests.
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------