I am not able to cast Object class to String class.
You're not casting an Object to a String, you're trying to use an int where a String is required. Try
memberId = new Integer(memberBean.getMemberId(userName)).toString();
The line
String userName = String.valueOf(session.getAttribute("userName"));
could be written as
String userName = (String) session.getAttribute("userName");
but it should work as it is.