out输出response.getWrite输出的区别
代码演示
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<%
out.write("out输出1 <br>");
out.flush();
out.write("out输出2 <br>");
response.getWriter().write("response输出1 <br>");
response.getWriter().write("response输出2 <br>");
/*out输出1
response输出1
response输出2
out输出2*/
%>
</body>
</html>
图解
out.write()和out.print()区别
由于jsp翻译之后,底层源码都是使用out来进行输出,所以一般情况下,我们在jsp页面统一使用out来进行输出。避免打乱页面输出内容的顺序
<%
out.write(12);//
out.print(12);//12
%>
<%--
out.write() 输出字符串没有问题
out.print() 输出任意数据都没有问题(都转换成为字符串后调用的write输出)
--%>
结论:在jsp页面中,可以统一使用 out.print() 来进行输出