The JSP and Javabean combined with simple examples have talked so much, and now I haven't seen the specific application, well, now let's take a look at the specific JavaServer Pages JavaBean example, let us take a look at a simple counter program. This routine contains three files javabean--counter.java files, JavaServer Page- counter.jsp files, counter1.jsp files, counter. Java is primarily used to count the counter counting operation, Counter.jsp and Counter1.jsp The file is mainly used to display the count of the web page.
Counter.java file package count; / ** * Title: Test * description: counter bean * @Author liuyufeng * @version 1.0 * / public class counter {// initialized JavaBean member variable int count = 0; // Class constructor Public counter () {} // GET method public int getCount () {// count operation, each request is made in counting count ; return this.count;} // Attribute Count SET method public void setcount (int count) {this.count = count;}} counter.jsp file