Conditional Bean Operations
Bean conditionally created
jsp:useBean results in new bean object only if no bean
with same id and scope can be found
If a bean with same id and scope is found, the preexisting
bean is simply bound to variable referenced by id
Bean properties conditionally set
replaced by
statements
The statements (jsp:setProperty elements) are executed
only if a new bean is created, not if an existing bean is
found
73
JSP
www.corewebprogramming.com
Conditional Bean Creation:
AccessCountBean
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);
}
public void setAccessCountIncrement(int increment) {
accessCount = accessCount + increment;
}
}
74
JSP
www.corewebprogramming.com
37