Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
13.4 Sharing Beans
307
             class="coreservlets.AccessCountBean"
             scope="application">
  
                   property="firstPage"
                   value="Current Page Name" />
Collectively, the pages using the counter have been accessed 
times.
Listing 13.8 shows the first of three pages that use this approach. The
source code archive at 
http://www.coreservlets.com/
 contains the other
two nearly identical pages. Figure 13 3 shows a typical result.
Listing 13.7 AccessCountBean.java 
package coreservlets;
/** Simple bean to illustrate sharing beans through
 *  use of the scope attribute of jsp:useBean.
 */
public class AccessCountBean {
  private String firstPage;
  private int accessCount = 1;
  public String getFirstPage() {
    return(firstPage);
  }
  public void setFirstPage(String firstPage) {
    this.firstPage = firstPage;
  }
  public int getAccessCount() {
    return(accessCount++);
  }
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved