<< Chapter < Page Chapter >> Page >

The following information about the objects is displayed in Figure 1 through Figure 3 :

  • counter information
  • information about each of the Date objects
  • information about the output stream object
  • information about the object of type MyClass .

Beginning with Figure 4 , the MyClass object is no longer contained in the session object when the list is constructed, so only information about the first three items inthe above list is displayed.

Miscellaneous things worthy of note

In Figure 1 , you see three types of information being displayed:

  • Event
  • Session Characteristics
  • Session Data

The Event output resulted from the fact that the object of type MyClass was put into the session object. This caused the valueBound method to be called.

The Session Characteristics show that the creation time and the time last accessed are equal, and the session is a new session.

The Session Characteristics also show the Session ID which has been automatically created for this session and the Session Context , which is peculiar to the Tomcat server being used. Neither of these will change for the duration of the session.

The Session Data in Figure 1 shows information on one counter object, one Date object, one output stream object, and one object of type MyClass .

Figure 1 through Figure 7 all show the same Session ID and the same Session Context .

(Note that unlike the servlet code in earlier modules, I did not write the code that created the session ID.)

In Figure 2 and Figure 3 , you see only two types of information being displayed:

  • Session Characteristics
  • Session Data

There is no event output in these two Figures because the object of type MyClass is neither putinto nor removed from the session during these calls to the servlet.

Beginning with Figure 2 , the New Session value shows false. In other words, the session is no longer new.

Beginning with Figure 3 , the Last Accessed time differs from the Creation Time .

The entire sequence of Figures show a sequence of seven calls to the servlet. Hence, the value of the counter increases by one in each succeeding Figure. Also, the numberof objects in the list increases by one during each of the first three Figures.

Figure 4 shows the screen output for the fourth call to the servlet. This is the call where the MyClass object was removed from the session object. Hence an Event occurred showing that the valueUnbound method was called.

The Session Data consists of one counter object, one output stream object, and four Date objects. The MyClass object no longer appears in the list because it was removed from the session object before thelist was constructed.

Finally, Figure 7 shows the screen output for the seventh call to the servlet. There is no Event output and the Session Characteristics are the same as before except for the time last accessed.

The Session Data consists of one counter object, one output stream object, and seven Date objects.

The inner class named MyClass

The code in Listing 9 defines an inner class named MyClass . It could have been implemented as a top-level class but I elected to make it an inner class (actually a member class ) .

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask