How to check what objects are stored in HttpSesession

You might want to check what objects are stored in HttpSession because either your application is throwing or during performance testing you want to check size of the objects stored in session.

The WebSphere Application Server ships a servlet that can be used to find out what is content of the session as well as size of the objects stored in session. The SessionInspectionServlet is part of AppServer/plugins/, which is already on your web applications class path. So in order to use the SessionInspectionServlet, you will have two choices

  1. Define the SessionInspectionServlet in your web.xml and map it to a URI

  2. Enable Serving servlets by class name, you can set this value in the ibm-web-ext.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <reload-interval value="3"/>
    <enable-directory-browsing value="true"/>
    <enable-file-serving value="true"/>
    <enable-reloading value="true"/>

    <enable-serving-servlets-by-class-name value="true" />


After making this change restart your web application and then access your web application so that the attributes/ objects are added into HttpSession, once that part is done you can access the SessionInspectionServlet and it will show you output like this

In my case i did create a simple SessionInspectionServletDemo servlet like this

package com.webspherenotes.session;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

* Servlet implementation class SessionInspectionServletDemo
public class SessionInspectionServletDemo extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().println("Inside SessionInspectionServletDemo");
HttpSession session = request.getSession();
session.setAttribute("testName", "testValue");
Contact c = new Contact();
session.setAttribute("contact", c);


Inside the doGet() method i a am adding a testName attribute with String value and a contact attribute with object of non Serializable Contact object as value.

I made changes in the Contact object to implement interface and now i can see that the SessionInspectionServlet servlet does not list it under the Non-Seiralizable object and it also shows the size of the session


srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store