Only call value methods if value != null

Avoids null pointer error when calling session.setAttribute("key", newAttributeValue);
when previousAttributeValue != null and newAttributeValue == null.