Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Saturday, December 1, 2007

How to use Bean Counter JSP in java

//File: BeanCounter.jsp




<%@ page language="java" %>




<%

out.println("Count from scriptlet code : "
+ counter.getCount() + "
");

%>

Count from jsp:getProperty :






///////////////////////////////////////////////////////////
//File: Counter.java
package beans;

import java.io.Serializable;

public class Counter implements Serializable{

// Initialize the bean on creation
int count = 0;

// Parameterless Constructor
public Counter() {

}

// Property Getter
public int getCount() {

// Increment the count property, with every request
count++;

return this.count;
}

// Property Setter
public void setCount(int count) {

this.count = count;
}
}

No comments: