java中的system.out.println()和JSP中out.println()差別

來源:互聯網
上載者:User

標籤:target   photo   tty   資訊   lin   ack   post   lis   htm   

out.println()輸出到client。    在out.println()中,out是response的執行個體。是以response為對象進行流輸出的,即將內容輸出到client。假設在JSP頁面中使用System.out.println(),在client僅僅會輸出一個空格。System.out.println()列印在控制台其中。

    System.out.println()用的是標準輸出資料流,這個是輸出在控制台上的。而JSP不是控制台程式。無論是在JSP還是在JAVA程式中,System.out.println()都是列印在控制台上。 假設想列印在頁面,簡單點的方法是:out.print( "要列印的內容" );     事實上在正規的網站建設中,是從來不用out.println()的,都是直接使用標籤。例:server平台:tomcat。

client:firefox瀏覽器。

來源程式://test.jsp檔案<%@page contentType="text/html;charset=gb2312"%><html><body> <%@ page import = "java.util.Date"%><%out.println("This is printed by out.println.");System.out.println("This is printed by System.out.println.");System.out.println("This is printed by System.out.println.");System.out.println("This is printed by System.out.println.");out.println("This is printed by out.println.");%> </body></html>client(瀏覽器)中的結果:從中可看出兩個out.println()輸出的內容間有一個空格(雖然來源程式調用了3次System.out.println)。控制台中的結果:從可看到調用3次System.out.println()的內容(其餘的是server資訊 )。

java中的system.out.println()和JSP中out.println()差別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.