Using Beans And Request Scope

The scope in which the Bean exists and the variable
named in id is available. The default value of scope is page.

request: In this scope bean object is placed in
the ServletRequest object for the current request only..

In this example we are making one bean class inside
which we are declaring one variable counter of type int. Inside this class
declare one setter and getter method. Now make one jsp page inside which declare
one standard tag <jsp:useBean> which is used to build the object of the
bean class. To set the the value of the setter method of the bean class in the
jsp use a scriptlet directive. Inside this directive call the setCounter()
defined in the bean class by the reference of the bean class. At last to get the
value which we have set in the setter method call the method getCounter()
defined in the bean class by the reference of the bean class. This method will
return how many times the page has been visited in the particular request.