From http://bbs.itzcn.com/thread-464-1-1.html
Can this method be used?
Use System. Out. println () You can only print the output content to the console. JSP Used in Out. println () Print the output content directly JSP I don't know how to solve this problem on the webpage?
As we all know, JSP When the page is executed for the first time JSP FileMediumCodeConvert Servlet Code format. After the conversion is complete Java Compile the file Class File. After compilation JVM RunProgram. After checking the converted Java File. JSP In Out Object in JavaBean Switch Jspwriter To solve this problem.
First define JavaBean : Javabeanprint , There is Print () Method, used in the method break Jspwriter Output a string of characters.
Package javabeanprint;
Import java. Io. ioexception;
Import javax. servlet. jsp. jspwriter;
Public class javabeanprint {
Public static void print (jspwriter out) throws ioexception {
Out. Print ("print information directly to the JSP page in JavaBean ");
}
}
ThenJSP.JSPPage isJavabeanprint. jspThe Code is as follows:
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML> <Title> Use Javabean to print information to the JSP page </title> <JSP: usebean id = "javabeanprint" class = "javabeanprint. javabeanprint" Scope = "page"/>
<Body>
<% Javabeanprint. Print (out); %>
</Body>
Figure4-3
Javabeanprint. jspPage running result