Print Information in Javabean to the JSP page

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.