JavaSercer Pages Figure 8.4 shows (1and1 web hosting) how the server

JavaSercer Pages Figure 8.4 shows how the server provides access to the two scopes for different clients. Figure 8.4. Session and application scopes The upcoming examples in this chapter will help you see how the session and application scopes can be used. 8.2.1 Counting Page Hits A simple page counter bean can be used to illustrate how the scope affects the lifetime and reach of shared information. The difference between the two scopes becomes apparent when you place the bean in both the session and application scopes. Consider the page shown in Example 8.4. Example 8.4. Page with Counter Beans (counter1.jsp) <%@ page language="java" contentType="text/html" %> <% String uri = request.getRequestURI( ); %>

Counter page

This page has been visited <%= sessionCounter.getNextValue(uri) %> times by the current user in the current session, and <%= applCounter.getNextValue(uri) %> times by all users since the application was started. page 93
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services

Comments are closed.