Methods for passing values between JSP pages

Source: Internet
Author: User

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 ----------------------------------------------------------------------------------------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.