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.