JSP built-in object---response response

Source: Internet
Author: User

Delete all HTML tags (including HTML, head, body) of the response.jsp page.

<%@ page language= "java" import= "java.util.*,java.io.*" contenttype= "text/html"; Charset=utf-8 "%>
<%
Response.setcontenttype ("Text/html;charset=utf-8");//Set the Mimi type of the response

Out.println ("Out.println ("
PrintWriter outer = Response.getwriter ();//Get Output Stream object
Outer.println ("Good evening, this response generates an output stream outer object");
%>

Page display:

Summary: The printerwriter output is ahead of the built-in out object, so the page appears as above.

Resolve this issue: Out.flush (); Forces the buffer to be emptied, and the flush () method forces the contents of the buffer to be written to the browser at the same time.

<%@ page language= "java" import= "java.util.*,java.io.*" contenttype= "text/html"; Charset=utf-8 "%>
<%
Response.setcontenttype ("Text/html;charset=utf-8");//Set the Mimi type of the response

Out.println ("Out.println ("Out.flush ();
PrintWriter outer = Response.getwriter ();//Get Output Stream object
Outer.println ("Good evening, this response generates an output stream outer object");
%>

Response.sendredirect () requests a redirect, a new request to the client, and redirects to the new resource. Example: When a user accesses response.jsp, it jumps to the reg.jsp page immediately

<%@ page language= "java" import= "java.util.*,java.io.*" contenttype= "text/html"; Charset=utf-8 "%>
<%
Response.setcontenttype ("Text/html;charset=utf-8");//Set the Mimi type of the response

Out.println ("Out.println ("Out.flush ();
PrintWriter outer = Response.getwriter ();//Get Output Stream object
Outer.println ("Good evening, this response generates an output stream outer object");
Response.sendredirect ("reg.jsp");//Jump to reg.jsp page immediately when user accesses response.jsp
%>

JSP built-in object---response response

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.