WebSphere Studio Application Developer part 27 provides integrated development tools for all e-business development roles, including Web developers, Java developers, business analysts, architects, and enterprise programmers. The customizable, targeted, role-based approach of WebSphere Studio Application Developer will be characteristic of all new products built on the WebSphere Studio Workbench. It is well integrated with WebSphere Application Server and provides built-in server test environments that can be used for testing and profiling Web applications | Figure 7-49 Creating a new life-cycle listener page 2 All the default values are suitable just click Finish to complete the wizard. The listener is created and added to the Web deployment descriptor. A Java editor is also opened on the listener class Java file. Editing the listener Switch to the Java editor that was opened on the file. The source code of the sample listener is available in sg246957 sampcode dev-web listener The first method we will enter calculates an object s size when serialized. This method is useful for determining how much space a session or one of its attributes would take if they would be serialized to a database. Add the size method as shown in Figure 7-50. 234 WebSphere Studio Application Developer Version 5 Programming Guide private int size Object anObject ByteArrayOutputStream array new ByteArrayOutputStream try new ObjectOutputStream array .writeObject anObject return catch lOException e return -1 Figure 7-50 Listener helper method size The next helper method that has to be created is called report. It handles the printing of messages to the standard output Figure 7-51 . private void report String reason HttpSession session Object value if value null reason session size size session else reason session size size session Attribute size size value Figure 7-51 Listener helper method report Now enter the life-cycle methods for the HttpSessionListener interface Figure 7-52 . public void sessionCreated HttpSessionEvent arg0 report Session created null public void sessionDestroyed HttpSessionEvent arg0 report Session destroyed null Figure 7-52 Listener implementation for the HttpSessionListener interface Finally enter the methods for the HttpSessionAttributeListener interface Figure 7-53 . Chapter 7. Developing Web applications 235 public void attributeRemoved .