Application of JavaBean in JSP

zhaozj2021-02-12  151

Application of JavaBean in JSP

JavaBean is a Java-based software component. JSP provides perfect support for integrating Javabean components in web applications. This support not only reduces development time (can directly utilize test and trusted components, avoid repeated development), but also bring more scalability for JSP applications. JavaBean components can be used to perform complex computing tasks or are responsible for interaction with the database and data extraction. If we have three Javabeans, they have functions of displaying news, stock prices, and weather conditions, and create a web page containing all three functions. It only needs to instantiate these three beans. You can use the HTML form to position them. . To illustrate the application of JavaBean in a JSP environment, we created a bean called TaxRate. It has two properties, namely Product (product) and RATE (tax rate). Two set methods are used to set these two properties, and the two GET methods are used to extract these two properties. In practical applications, this bean should generally extract tax rates from the database, which we simplifies this process, allowing any set tax rate. Below is this bean code list: package tax; public class taxrate {string product; double rate; public Taxrate () {this.Roduct = "A001"; this.rate = 5;} public void setProduct (String product "{THIS .Product = ProductName;} public String getProduct () {return (this.Product);} public void setRate (double rateValue) {this.Rate = rateValue;} public double getRate () {return (this.Rate);}} Apply the above Bean to the tag in the JSP page. Depending on the different JSP engine, where it is configured and how to configure bean may also be slightly different. This article puts this bean .class file in the C: .0inf directory, the Tax here is a directory that is specifically stored.

转载请注明原文地址:https://www.9cbs.com/read-6437.html

New Post(0)