SessionInspectServlet

WebSphere Application Server Ships com.ibm.ws.webcontainer.httpsession.SessionInspectServlet servlet that you can use to investigate what content is stored in HttpSession of your application. The SessionInspectServlet will tell you


  1. Names of the session attributes

  2. Size of the data in session attribute

  3. If the attribute is serializable or not



You might want to use this when you start getting NotSerializableException or you run into performance issue due to size of data stored in session.

You can follow these steps to add SessionInspectorServlet to your web application

  1. Add Session Inspector servlet to web.xml file of your web application

    <servlet>
    <display-name>SessionInspectServlet</display-name>
    <servlet-name>SessionInspectServlet</servlet-name>
    <servlet-class>com.ibm.ws.webcontainer.httpsession.SessionInspectServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>SessionInspectServlet</servlet-name>
    <url-pattern>/SessionInspectServlet</url-pattern>
    </servlet-mapping>

    You dont have to include any jars in your web application. If you search for SessionInspectServlet class you will notice that it is part of WebSphere/AppServer/plugins/com.ibm.ws.webcontainer_2.0.0.jar, which is websphere runtime so you can use that class without including it in your web application

  2. Install and start your web application on server

  3. Access the SessionInspectorServlet by going to /webcontext/SessionInspectorServlet url

    This is the output that i get for my webapplication, i am storing object of Contact class in session that does not implement Serializable interface and a String, String is serializable