An example of response object usage in Java _java

Source: Internet
Author: User

The examples in this article describe the use of response objects in Java. Share to everyone for your reference, specific as follows:

<jsp:forward> action elements are used by the runtime to end the current page execution on the server side and move from the current page to the specified page.

Use the SetHeader () method of the response object to set the automatic refresh interval for the page. The statement that implements the reload of this page every 60 seconds is:

Copy Code code as follows:
Response.setheader ("Refresh", 60);

and 3 seconds after the implementation of the browser load new page http://www.jb51.net statement is:
Copy Code code as follows:
Response.setheader ("Refresh", "3; Url=http://www.jb51.net ");

Response method: void Sendredirect (String url) to redirect the page to the specified URL address.

Example: Using response to implement user login capabilities

login.html for Login Form page
LOGIN.JSP is an information processing page that verifies the success of a user login.
Success.jsp is the jump page after successful login.

Login.html's source code is as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
 
 

Login.jsp's source code is as follows:

<%@ page language= "java" import= "java.util.*" contenttype= "Text/html;charset=utf-8"%> <% String Path = Request
. Getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >  

The source code for the

success.jsp is as follows:

<%@ page language= "java" import= "java.util.*" contenttype= "Text/html;charset=utf-8"%> <% String Path = Request
. Getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >  

I hope this article will help you with your Java programming.

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.