The difference between forward redirdbms redirection and redirection is that El and Java code are used to retrieve parameters on the JSP page. Notes for JSP: Param

Source: Internet
Author: User

Some code has been commented out because it has an impact on other code during local debugging.

 

1. Redirection/Refers to 127.0.0.1,
If not, add the specified Page name from akazamtest01.
There cannot be two response. sendredirect ("")
If the HTTP path is added, it will jump directly to the domain name
After redirection, the following code will be executed and may be flashed.
Test method: jump to a foreign website and display the redirected content on the page after loading for a long time.


2. Switch/Refers to 127.0.0.1/akazamtest01
The following code will not be executed after turning
Forward transmits parameters to the next page through JSP: Param

<Body>
1. Redirection/Refers to 127.0.0.1,
If not, add the specified Page name from akazamtest01.
There cannot be two response. sendredirect ("")
If the HTTP path is added, it will jump directly to the domain name
After redirection, the following code will be executed and may be flashed.
Test method: jump to a foreign website and display the redirected content on the page after loading for a long time.
2. Switch/Refers to 127.0.0.1/akazamtest01
The following code will not be executed after turning
Forward transmits parameters to the next page through JSP: Param
<%
// Response. sendredirect ("Logon. jsp? B = 1 ");
// Response. sendredirect ("http://www.baidu.com ");

%>
<% Int I = 9; request. setattribute ("name", "akazam"); %> -- the value must be written here.
<JSP: Forward page = "bean/index. jsp? Method = forward ">
<JSP: Param value = "$ {name}" name = "name"/>
<JSP: Param value = "2" name = "name1"/>
<% Int I = 9; request. setattribute ("name", "akazam"); %> JAVA code cannot be written here
<JSP: Param value = "<% = I %>" name = "name2"/>
</Jsp: Forward>

</Body>

 

Otherwise, the following error occurs:

The above code uploads Parameters

The parameters are retrieved as follows:

 

<Body>
Parameters after the address is retrieved: <br/>
$ {Param. Method} <br/>
I passed it from index JSP in the root directory <br/>
This is obtained using Java code <br/>
<% = Request. getparameter ("name") %>
Equivalent to: <% Out. print (request. getparameter ("method"); %> the difference is that <B> <font color = "red" >;</font> </B> must be written here.

<Br/>
This is obtained using the El expression. <br/>
$ {Param. name}
<Br/>
Two Methods: print the value on the page
<% Int I = 0; %> -- local variable of the Method
<% Out. Print (++ I); %> <br/>

This is generally not easy to use.
<%! Int J = 0; %> -- the member variable declared as servlet, which is a global variable. Multiple Clients share one copy.
<% = ++ J %>
</Body>

 

Run:

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.