Common page Jump methods in HTML/jsp

Source: Internet
Author: User

First:
<Script language = "JavaScript" type = "text/JavaScript">
Window. Location. href = "login. jsp? Backurl = "+ window. Location. href;
</SCRIPT>

Second:
<Script language = "JavaScript">
Alert ("return ");
Window. History. Back (-1 );
</SCRIPT>

Third:
<Script language = "JavaScript">
Window. navigate ("Top. jsp ");
</SCRIPT>

Fourth:
<Script language = "JavaScript">
Self. Location = "top.htm ";
</SCRIPT>

Category 5:
<Script language = "JavaScript">
Alert ("illegal access! ");
Top. Location = "XX. jsp ";
</SCRIPT>

 

Sixth:

Servlet jump --> request. getrequestdispatcher ("/WEB-INF/pages/error. jsp"). Forward (request, response );

 

7:

Because the above redirects are all under webroot, or the complete URL address is known. if HTML or JSP is stored in the WEB-INF, in the case of struts, you can get the complete URL address by configuring the struts path, do not use struts to achieve page Jump under the WEB-INF...

/** <Br/> * @ author Vicky <br/> * @ emial eclipser@163.com <br/> */<br/> public class navigateto extends httpservlet {</P> <p> Private Static final long serialversionuid = 1l; </P> <p> Public void doget (httpservletrequest request, httpservletresponse response) throws servletexception, <br/> ioexception {<br/> string url = request. getparameter ("url"); <br/> request. getrequestdispatcher (URL ). forward (request, response); <br/>}</P> <p> Public void dopost (httpservletrequest request, httpservletresponse response) throws servletexception, <br/> ioexception {<br/> doget (request, response); <br/>}</P> <p>}

Web. xml configuration:

<Servlet>
<Servlet-Name> navigateto </servlet-Name>
<Servlet-class> CN. Vicky. servlet. navigateto </servlet-class>
</Servlet>

Page used:

<%
String Path = request. getcontextpath ();

%>

<SCRIPT type = "text/JavaScript">
Function playgame ()
{
Window. Location. href = "<% = PATH %>/servlet/navigateto? Url =/WEB-INF/pages/game. jsp ";
}
</SCRIPT>

<Input type = "button" value = "enter the game" $ {sessionscope. User = NULL? "Disabled = 'false'": ""} onclick = "playgame ();"/>

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.