I'm sure there is nothing new in the Java EE6 world (however, JEE5, I know quite well).
My environment is Glassfish 3.1.2
I am trying to embed servlet objects in a CDI bean (pojo annotated with @Named and @ * Scoped) which is called for jsp with $ {nameofBean.nameofMethode (par1 ...)}
I try this:
@Inject private ServletContext context; (or HTTPServletRequest or HttpServletResponse (for calling sendRedirect))
Which gives me the following deployment exception: WELD-001408 Unsatisfactory dependencies for type [ServletContext] with qualifiers [@Default] at the injection point
Apparently this might work on JBoss: http://docs.jboss.org/seam/3/servlet/latest/reference/en-US/html/injectablerefs.html
One of my ideas was to use @Produces, but so far I have not figured out how to do this.
Perhaps the word why I want to do this:
I want to do some CRUD things, but I don't know how to handle exceptions. So my idea is to create a CDI Bean that is invoked by the JSP and which invokes some ejb in the backend. If EJB throws an exception, I want to catch this in a CDI bean and something with a request object (redirect somewhere, set message ...). With the introduction of the servlet context, I would also gain access to the POST parameters. I want to avoid using servlets to support jsps and getting in touch with ejbs (I think it's too ld-fashioned).
thanks for the help
Willow
source share