0

I have used DI to inject a Stateful Session Bean across 3 servlets (which take data from forms across 3 JSP pages), so that data received by all 3 servlets can be stored in it. When I print all the data of the Bean in the last servlet, it gets printed successfully.

However when I try to print the same data of the bean on a JSP using <jsp:useBean> tag, and scope=session all data shows null. I tried using InitialContext to get the bean using JNDI but it could not find the required bean (probably because I injected the bean using DI!). I even tried putting the EJB bean in an HttpSession but it threw a ClassCastException.

How do I print the values of my Stateful Session Bean on a JSP?

  • When the same DI used in servlets, is tried in `` JSP scriptlet tag, an error is generated which says 'annotation type not applicable to this kind of a declaration'. Tried using both `@EJB` and `@Inject`. – Mangesh Kherdekar Apr 23 '14 at 02:35

1 Answers1

0

Found the solution! Marked the session bean with @SessionScoped annotation