The seven-way javaweb of different JSP pages in development __HTML5

Source: Internet
Author: User

Think about learning Javaweb has been for some time now, summarize the method of passing parameters between JSP pages 1. Using JavaBean

JavaBean class:

Package entity;

public class User {
    private String username= "";
    Private String gender= "";
    Public String GetUserName () {return
        username;
    }
    public void Setusername (String username) {
        this.username = username;
    }
    Public String Getgender () {return
        gender;
    }
    public void Setgender (String gender) {
        this.gender = gender;
    }
    Public User () {
    }
}

Pages that pass parameters

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Page to receive parameters

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >  

Test results:

To pass the parameter page:

Receive Parameters page:
2. Bind to Session Object

To pass the parameter page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Receive Parameters page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

As the results of the test were successful, bloggers did not figure 3. Bind to Application

To pass the parameter page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Receive Parameters page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
4. Bind to Request object

This is the way to request forwarding.
To pass the parameter page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Receive Parameters page

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Test results:
Because is the request forwarding so the page quickly jumps to receive the parameter the page, therefore the running result does not display the pass parameter the content, but the browser address is delivers the page the address

Indicates that the parameter has been successfully passed through 5. Use JSP action instruction to pass parameters

Pass-Parameter page

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Receive Parameters page:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
    pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

This is also the way to request forwarding 6. Table conveys parameter

Pass-Parameter page

<%@ page language= "java" contenttype= "text/html; charset=utf-8" pageencoding= "UTF-8"% > <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > 
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.