January 6, 2011

0 Understanding JSP Object Scope

Task 1
Develop a simple counter bean, CounterBean.java.
Develop a bean which can maintain a count within say, an integer
property. Provide at least a getter method for this property.

Task 2
Compile the counter bean.
You can compile the bean as javac CounterBean.java

Task 3
Deploy the bean within Tomcat.
Copy CounterBean.class to
You will need to create the directories below classes for the package the
bean is in.

Task 4
Develop a JSP page, Counter.jsp, which creates two instances of the
counter bean, one with session scope, and the other with application

You can use the jsp:useBean tag for instantiating the beans. Make sure
you provide the appropriate scope for the scope attribute.

Task 5
Deploy the JSP file for the example within Tomcat.
Assuming you have installed Tomcat in say, \jakarta-tomcat, copy the JSP
file to \jakarta-tomcat\webapps\examples\jsp\jdc\counter\Counter.jsp

Task 6
Run the example.
From your browser (say, Netscape Navigator), access the URL
Now, start up a different browser (say, MSIE) access the URL

(Note: If you use only MSIE, you can simply double click on the browser
icon again to run a second instance of MSIE as a separate process. This
is important to ensure that the browser creates a new session and does
not reuse the one created by an earlier instance.)
Click a few times within both browser to increment the counters for the
beans with session and application scope. Observe the difference
between the two counts


Post a Comment

Blogger Themes

Powered by Blogger