java如何把控制台打印的数据显示到jsp页面? 怎么把eclipse控制台上的内容显示到jsp网页上?
java\u4ee3\u7801 \u63a7\u5236\u53f0\u8f93\u5165\u8f93\u51fa \u5982\u4f55\u5c06\u63a7\u5236\u53f0\u8f93\u51fa\u7684\u5185\u5bb9\u653e\u5230jsp\u91cc \u6025\uff01\uff01\uff01\uff01\u9996\u5148\u4f60\u53ef\u4ee5\u4f7f\u7528\u5730\u5740\u4f20\u503c\uff0c
\u5176\u6b21\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528Servlet\u914d\u7f6e\uff0c\u653e\u5230request\u6216\u8005session\u4e2d\u3002
\u7136\u540e\u5728jsp\u4e2d\u53d6\u503c\u5c31\u53ef\u4ee5\u4e86\u3002
Servlet\u4e2d\u4f7f\u7528
PrintWriter out=response.getWriter()
out.println("\u5185\u5bb9")
jsp\u9875\u9762\u4e2d\u4f7f\u7528
out.println("\u5185\u5bb9")
request.getRequestDispatcher("/mycart.jsp")
.forward(request, response);
首先你需要把信息发送到jsp页面,request
绛旓細姣斿锛歱ublic static void main(String[] args) throws FileNotFoundException { System.setOut(new PrintStream(new File("d:/test_out.txt")));System.out.println("浣犲ソ");System.out.println("璇疯繘");}
绛旓細IOException { File f=new File("out.txt");f.createNewFile();FileOutputStream fileOutputStream = new FileOutputStream(f);PrintStream printStream = new PrintStream(fileOutputStream);System.setOut(printStream);System.out.println("榛樿杈撳嚭鍒鎺у埗鍙扮殑杩欎竴鍙ワ紝杈撳嚭鍒颁簡鏂囦欢 out.txt");} } ...
绛旓細import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStream;public class WriteOut { public static void main(String[] args) throws IOException { LogWriter.log("log info...");} } class LogWriter { // 鍙互鍐欎綔閰嶇疆锛歵rue鍐欐枃浠; false杈撳嚭鎺у埗鍙 private ...
绛旓細import java.io.*;public class Linux { public static void main(String[] args) throws IOException { //灏嗘牴鐩綍涓嬬殑鏂囦欢鍒楀嚭骞跺皢缁撴灉鍐欏叆 /tmp/list.out Process p = Runtime.getRuntime().exec("ls -al /");InputStream in = p.getInputStream();OutputStream out = new FileOutput...
绛旓細涓変釜姝ラ 绗竴姝ワ細棣栧厛缂栧啓JAVA绫 public class Test{} 杩欎釜绫婚噷鍐欎釜main鏂规硶 public class Test{ public static void main(String[] args){ } } 杩欎釜main鏂规硶閲屽啓涓涓緭鍑鸿鍙 public class Test{ public static void main(String[] args){ ystem.out.println("Hello World");} } 绗簩姝ワ細...
绛旓細java涓鍙互浣跨敤scanner鎺ュ彈鐢ㄦ埛浠鎺у埗鍙杈撳叆鐨勫弬鏁帮紝浣跨敤瀹炰緥濡備笅锛歩mport java.util.Scanner;public class ScannerTest { public static void main(String[] args) { Scanner s = new Scanner(System.in);//鎺ュ彈浠庨敭鐩樿緭鍏鐨勬暟鍊 //receive string String str = s.next();//鑾峰彇杈撳叆鐨勫弬鏁 ...
绛旓細import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;public class StudentManager { private final static int MAX_SIZE = 10;private int length;public StudentManager(){ length = 0;} public void display() throws IOException{ / 閲囩敤鎺у埗鍙鍔ㄦ佽緭鍏鏁版嵁 / Bu...
绛旓細java鎺у埗鍙杈撳嚭鐢眕rint( ) 鍜 println( )鏉ュ畬鎴愭渶涓虹畝鍗曘傝繖涓ょ鏂规硶鐢眗intStream(System.out寮曠敤鐨勫璞$被鍨)瀹氫箟銆傚敖绠ystem.out鏄竴涓瓧鑺傛祦,鐢ㄥ畠浣滀负绠鍗曠▼搴忕殑杈撳嚭鏄彲琛岀殑銆傚洜涓篜rintStream鏄粠OutputStream娲剧敓鐨勮緭鍑烘祦,瀹冨悓鏍峰疄鐜颁綆绾ф柟娉晈rite(),write()鍙敤鏉ュ悜鎺у埗鍙板啓鏁版嵁銆侾rintStream 瀹氫箟鐨剋rite( )鐨...
绛旓細java涓杈撳嚭鐨勫揩鎹锋柟寮 姝ラ濡備笅鎵绀猴細1銆侀鍏堬紝鍏堣璇磋緭鍑哄唴瀹癸紝杩欎釜姣旇緝绠鍗曘傛墦寮eclipse锛岀劧鍚庡湪涓诲嚱鏁颁腑涔﹀啓杩欐潯璇彞鍗冲彲杈撳嚭锛岃緭鍑虹殑鍐呭瑕佺敤鍙屽紩鍙峰紩璧锋潵鍝︺2銆佹帴鐫杩愯java绋嬪簭锛岀劧鍚庡氨浼氱洿鎺ュ湪鎺у埗鍙版墦鍗鎴戜滑鐨勮緭鍑哄唴瀹逛簡銆3銆佽宩ava鑾峰彇浠庨敭鐩樼殑鍐呭鍒欓渶瑕佸鍏ヤ竴涓被锛屽鍥撅紝杩欎釜绫诲氨鏄疭canner绫...
绛旓細鎮ㄥソ锛屼唬鐮佸涓嬶細import java.util.Scanner;public class InputTest { public static void main(String[] args) { Scanner input = new Scanner(System.in);String val = null; // 璁板綍杈撳叆鐨勫瓧绗︿覆 do{ System.out.print("璇疯緭鍏ワ細");val = input.next(); // 绛夊緟杈撳叆鍊 System.out....