MCPcopy Create free account
hub / github.com/apache/tomcat / getWriter

Method getWriter

java/org/apache/catalina/connector/Response.java:524–549  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

522
523
524 @Override
525 public PrintWriter getWriter() throws IOException {
526
527 if (usingOutputStream) {
528 throw new IllegalStateException(sm.getString("coyoteResponse.getWriter.ise"));
529 }
530
531 if (request.getConnector().getEnforceEncodingInGetWriter()) {
532 /*
533 * If the response's character encoding has not been specified as described in
534 * <code>getCharacterEncoding</code> (i.e., the method just returns the default value
535 * <code>ISO-8859-1</code>), <code>getWriter</code> updates it to <code>ISO-8859-1</code> (with the effect
536 * that a subsequent call to getContentType() will include a charset=ISO-8859-1 component which will also be
537 * reflected in the Content-Type response header, thereby satisfying the Servlet spec requirement that
538 * containers must communicate the character encoding used for the servlet response's writer to the client).
539 */
540 setCharacterEncoding(getCharacterEncoding());
541 }
542
543 usingWriter = true;
544 outputBuffer.checkConverter();
545 if (writer == null) {
546 writer = new CoyoteWriter(outputBuffer);
547 }
548 return writer;
549 }
550
551
552 @Override

Callers 7

testSetContentType02Method · 0.95
testSetContentType05Method · 0.95
testSetLocale02Method · 0.95
testSetLocale05Method · 0.95
sendRedirectMethod · 0.95

Calls 6

setCharacterEncodingMethod · 0.95
getCharacterEncodingMethod · 0.95
getStringMethod · 0.65
getConnectorMethod · 0.45
checkConverterMethod · 0.45

Tested by 6

testSetContentType02Method · 0.76
testSetContentType05Method · 0.76
testSetLocale02Method · 0.76
testSetLocale05Method · 0.76