Implement jsp redirection webpage effects and jsp redirection webpage

Source: Internet
Author: User

Implement jsp redirection webpage effects and jsp redirection webpage

Use the sendRedirect () method in the request object to redirect (webpage jump) to another page.

Format: request. sendRedirect ("*. jsp ");

And forwarding The difference: the former can jump to any address page, and the latter can only jump to this website. The former jumps with the information in the request, and the latter does not.

For example, you can enter the logon name and password on the logon page, and enter the correct and wrong passwords to go to different pages.

Code:

Login. jsp

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> 

Receive. jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<% String name = request. getParameter ("rdname"); String passwd = request. getParameter ("rdpasswd"); if (name. equals ("abcd") & passwd. equals ("123456") {%> <%} Else {%> <% response. sendRedirect ("https://sohu.com");} %> Correct. jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% String name = request. getParameter ("rdname"); %> welcome, <% = name %> login successful! Running result (correct ):

Running result (error ):

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.