Various Java related page jumps

Source: Internet
Author: User

AK believe that the page jump in this circle is a circle of people can often encounter things, AK also in peacetime work in the study recorded some, here to do a small summary, there are any doubts and doubts are hoping you can tell me, do not worry about the consequences, must at least you can also talk me, ak extremely grateful ...

1. \* page link type: *\

<a href= "Javascript:history.go ( -1)" > Back to Previous </a>

2.\* page button type: *\

<input name= "AK" type= "button" value= "Go" onclick= "location.href= ' http://www.baidu.com/'" >

3.\* Direct Jump type:*\

<script>window.location.href= ' aklovebb.html ';</script>

jump in 4.\*js: *\

1. window.location.href= "http://www.baidu.com" or location.href= "ak_bb.jsp"

2.window.history.back (-1); //Return

3.self.location= "ak_bb.html";

4.top.location= ' bb_ak.jsp '; //This method is to let the top-level page jump

5.\* Request Forwarding: *\

HttpServletRequest request.getrequestdispatcher ("ak_bb.html"). Forward (request,response);

Also called the request dispatch, the page content jumps to the ak_bb.html, but the current page's address does not change.

This can also be implemented in JSPs:<jsp:forward page= "ak_bb.jsp"/>

6.\* Request Redirection: *\

httpservletresponse response.sendredirect ("bb_ak.jsp");

Unlike forwarding, redirects are content and addresses that go to bb_ak.jsp.

Redirects can also be implemented in JSP:<%response.sendredirect ("bb_ak.jsp")%>

of course request forwarding and redirection of the different original is not so simple, the following is a simple enumeration of their differences:

1 forwards access to the server only once, and redirect the Access server two times.

2 "forwarding can only see the URL of the first access page, the future work is done by the server; redirection is the URL where you can see the target page.

3 "Forwarding is the execution of the jump page, the following code will not be executed, redirect after the jump must add return, otherwise the page jumps, but also executes the statement after the jump.

4 "Before and after the forwarding is to share a request and reponse, and redirect after the jump is generated new request and reponse.

5 "Request forwarding can only access their own web application resources, redirect can access external resources, in short, Response.sendredirect (" http://www.baidu.com ");

If you are not satisfied with the enumeration of AK, want to know more detailed, for you to recommend an article: http://blog.csdn.net/getstudymessages/article/details/6230325

Various Java related page jumps

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.