No. This is not directly related to the RequestDispatcher question. You have to remember that you get the IllegalStateException because you cannot invoke both getWriter() and getOutputStream on the same response object. (Nothing to do with RequestDispatcher in this case.)
java.lang.IllegalStateException: getOutputStream() has already been called for this response
forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException.
Uncommitted output in the response buffer is automatically cleared before
The servlet container is responsible for loading and instantiating servlets. The loading and instantiation can occur when the container is started, or delayed until the container determines the servlet is needed to service a request. When the servlet engine is started, needed servlet classes must be located by the servlet container.
However, the container handles the create and remove calls without necessarily creating and removing an EJB instance".
So we can access the EJBObject in the ejbCreate() of the Stateless Session bean.
that the container will pull a bean instance from the pool and associate the instance with its SessionContext and EJBObject by invoking the bean's setSessionContext() and ejbCreate() methods.
It means you as a bean developer can get a reference to the EJBObject[/QB]
Originally posted by Kev Miller:
on page 227 (Head First EJB) it says that ejbCreate is invoked by the container without a client request. On the following page, however, it says that you can get a reference to your EJBObject from within ejbCreate. How can you get such a reference when the container invokes ejbCreate without any client request? Isn't an EJBObject instance only created when the client invokes create on his home object stub (whereas the EJBObject instance is not linked to an actual bean instance until a business method call)?
But, how can we access resource managers in ejbCreate() and ejbReomve() methods? I know these run in unspecified transaction. So, is this unspecified transaction a 'meaning transaction context'?
Given a remote client R, that has valid reference to session beans A and B
1. R cannot pass his reference for A, to B
and given that A is a local client to B