Setting response message body

Setting response message body

Transfer text messages
// 1. acquiring character output stream 
    the PrintWriter OUT = resp.getWriter (); 

// 2. written text information 
    Out.print ( "text information"); // do not wrap 
    Out.println ( "text information"); // wrap
     // If the text message is html document, the browser will parse and display its
Binary file transfer
// 1. obtain a binary output stream 
    the ServletOutputStream Sout = resp.getOutputStream (); 

// 2. output 
    sout.write ( "byte information" ); 

// Use the text column -> Security image

Setting redirect requests

Redirection Features : two requests, in response to two

// redirect principle
     // 1. Set status code, usually beginning with 3 302 
        resp.setStatus (302 ); 

    // 2. tell the client, the new url- address 
        resp.addHeader ( "Location", "address " );
         // address may be a relative location, or an absolute path
         // local typically use a relative path 
    
    // * The above method has a packaging method 
        resp.sendRedirect (" address ")

Set the automatic refresh and wait for the page

// page refresh 
    resp.addHeader ( "Refresh", "5 ; url jump page" );
     // 5; -> If the second argument is only number that refresh the current page, has been based on the time to refresh
     // 5 ; jump url of the page -> 5 seconds after the jump to a new page

 

other

  1. Image verification code is

Guess you like

Origin www.cnblogs.com/-Archenemy-/p/12668467.html