Here you can do it by using HttpRequest
or HttpSession
. And think your problem is within the JSP.
If you are going to use the inside servlet do following,
Object obj = new Object();
session.setAttribute("object", obj);
or
HttpSession session = request.getSession();
Object obj = new Object();
session.setAttribute("object", obj);
and after setting your attribute by using request or session, use following to access it in the JSP,
<%= request.getAttribute("object")%>
or
<%= session.getAttribute("object")%>
So seems your problem is in the JSP.
If you want use scriptlets it should be as follows,
<%
Object obj = request.getSession().getAttribute("object");
out.print(obj);
%>
Or can use expressions as follows,
<%= session.getAttribute("object")%>
or can use EL as follows,
${object}
or ${sessionScope.object}